# Testing emacsPackages

**URL:** https://discourse.nixos.org/t/testing-emacspackages/24417
**Category:** Nixpkgs Architecture
**Created:** [January 3, 2023, 10:10pm UTC](https://discourse.nixos.org/t/testing-emacspackages/24417 "2023-01-03T22:10:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fxttr](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/e68b1a/32.png) [@fxttr](https://discourse.nixos.org/u/fxttr)
#### Post date: [January 3, 2023, 10:10pm UTC](https://discourse.nixos.org/t/testing-emacspackages/24417/1 "2023-01-03T22:10:46Z")

</div>

Hey!

I think the idea of NixOS is great and I would like to contribute to the project. First I will try to submit a first nixpkg and maintain it. It is an emacsPackage.

I followed the following instructions: [Nixpkgs/Create and debug packages - NixOS Wiki](https://nixos.wiki/wiki/Nixpkgs/Create_and_debug_packages)

Everything worked fine, the only problem is that I don’t know how to test the package.

```auto
nix-build $NIXPKGS --run-env -A emacsPackages.lsp-bridge

```

works without problems, but I need to run

```auto
nix-shell $NIXPKGS -p (pkgs.emacsPackagesFor pkgs.emacs28).emacsWithPackages(epkgs: [pkgs.emacsPackages.lsp-bridge])

```

to add the package to the load-path from emacs.

But it says undefined variable lsp-bridge. does anyone have a tip how to test new emacs nixpkgs?

This is my default.nix:

```auto
{ lib
, trivialBuild
, fetchFromGitHub
, writeText
, python310Packages
, posframe
, markdown-mode
, yasnippet
}:

let
  rev = "7dfeeb640d14697755e2ac7997af0ec6c413197f";
in trivialBuild {
  pname = "lsp-bridge";
  version = "20230103";

  commit = rev;

  src = fetchFromGitHub {
    owner = "manateelazycat";
    repo = "lsp-bridge";
    inherit rev;
    sha256 = "sha256-sB5niigN0rdtqeprlZAJEKgAuQDkcUMbbL9yTnrdoLg=";
  };

  packageRequires = [
    python310Packages.epc
    python310Packages.orjson
    python310Packages.sexpdata
    python310Packages.six
    posframe
    markdown-mode
    yasnippet
  ];

  meta = {
    description = "Lsp-bridge's goal is to become the fastest LSP client in Emacs.";
    longDescription = ''
        Lsp-bridge uses python's threading technology to build caches that bridge Emacs and LSP server.
        Lsp-bridge will provide smooth completion experience without compromise to slow down emacs' performance.
      '';
    license = lib.licenses.gpl3;
    maintainers = with lib.maintainers; [fxttr];
  };
}

```

- fxttr

---

<div class="post-metadata">

### Author: ![tobiasBora](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/9de0a6/32.png) [@tobiasBora](https://discourse.nixos.org/u/tobiasBora)
#### Post date: [January 3, 2023, 10:47pm UTC](https://discourse.nixos.org/t/testing-emacspackages/24417/2 "2023-01-03T22:47:25Z")

</div>

I’m not an expert in emacs packaging, but first it depends what you mean to “test” your package. Are you testing your derivation directly, or the integration of this derivation into nixpkgs? If you just want to test the derivation, you don’t need any copy of nixpkgs, you should be able to just call your package with `epkgs.callPackage ./default.nix {}`, with something like:

```auto
nix-shell -p "(pkgs.emacsPackagesFor pkgs.emacs28).emacsWithPackages(epkgs: [(epkgs.callPackage ./default.nix {})])"

```

If you want to integrate it in nixpkgs, and if the package is not present in elpa/melpa, then you can add it in the list in `pkgs/applications/editors/emacs/elisp-packages/manual-packages.nix` with something like:

```auto
# …
# make sure to move your default.nix in pkgs/applications/editors/emacs/elisp-packages/lsp-bridge/default.nix
lsp-bridge = callPackage ./lsp-bridge {};
# …

```

Then, it should appear as any other package I guess (but I’ve not tested), using something like:

```auto
$ nix-shell -I nixpkgs=$HOME/nixpkgs -p "(emacsPackagesFor pkgs.emacs28).emacsWithPackages (epkgs: [epkgs.lsp-bridge])"

```

---

<div class="post-metadata">

### Author: ![fxttr](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/f/e68b1a/32.png) [@fxttr](https://discourse.nixos.org/u/fxttr)
#### Post date: [January 4, 2023, 5:14am UTC](https://discourse.nixos.org/t/testing-emacspackages/24417/3 "2023-01-04T05:14:11Z")

</div>

Hey,

```auto
nix-shell -p "(pkgs.emacsPackagesFor pkgs.emacs28).emacsWithPackages(epkgs: [(epkgs.callPackage ./default.nix {})])"

```

seems to do what I want. Thanks! I already added it to manual-packages.nix, it’s not in melpa/elpa.

```auto
nix-shell -I nixpkgs=$HOME/nixpkgs -p "(emacsPackagesFor pkgs.emacs28).emacsWithPackages (epkgs: [epkgs.lsp-bridge])"

```

Also works. Seems like I forgot the -I.  
Would it make sense to add this to the wiki entry?

---

<div class="post-metadata">

### Author: ![tobiasBora](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/9de0a6/32.png) [@tobiasBora](https://discourse.nixos.org/u/tobiasBora)
#### Post date: [January 4, 2023, 7:40am UTC](https://discourse.nixos.org/t/testing-emacspackages/24417/4 "2023-01-04T07:40:36Z")

</div>

Sure, feel free to edit the wiki if something is unclear. Note that you might want to edit the emac specific page in [Emacs - NixOS Wiki](https://nixos.wiki/wiki/Emacs)

PS: to help people to quickly see that the issue is solved (this way they can only open non-solved issues), it’s a good idea to mark the solution as a solution.

**edit** ahah the solution button is different from the like button ^^ You can put only one solution, which will be reported appropriately when searching unsolved packages, unlike likes. But nevermind ^^
