Borg-nix-shell: build Borg packages with Nix-Shell
Borg is a package manager for Emacs storing packages as Git submodules. Unlike package.el, Borg requires that all packages be built locally. In most cases, all it takes is byte-compiling a few Emacs-Lisp files, which Borg can do in a totally transparent manner. But some packages require external build tools or libraries, which may not be available on all systems, or not easily installable.
Borg-nix-shell plugs into Borg to run build-steps through nix-shell, from the Nix package manager.
Usage
Assimilate borg-nix-shell (or just copy borg-nix-shell-build-command somewhere in your init.el) then:
(setq borg-build-shell-command 'borg-nix-shell-build-command)Then, for each package requiring it:
- Set
submodules.DRONE.build-nix-shell-packagesto a list of packages to pass tonix-shellwith the-pargument. - Or set
submodules.DRONE.build-nix-shell-fileto the path of a Nix file, which will be passed tonix-shellas the last positional argument.
If none of these variables are provided, borg-nix-shell adds an empty -p argument to nix-shell unless the drone’s work tree has a shell.nix or default.nix at its root, in which case no arguments are added and nix-shell should pick the correct file.
As an example, here’s how I configure PDF Tools:
[submodule "pdf-tools"] path = lib/pdf-tools url = git@github.com:politza/pdf-tools.git build-nix-shell-packages = gnumake automake autoconf pkgconfig libpng zlib poppler_gi build-step = make ./server
Configuration
There’s a borg-nix-shell-build-use-pure-shell variable which determines if nix-shell should be passed the --pure flag. It defaults to t, and you really, really shouldn’t change it.