Customizing Nix packages

I’m using Nix to install some packages on a host where I don’t have root and do not want to pester the admins all the time. The good side of this is that I can install packages with one command. The bad side is that installing anything takes forever. Because I use a custom store location, I can’t use the binary packages. Nix builds all the dependencies (including e.g. gcc and glibc), which takes a while.

Some Nix packages can customized. For example, I wanted to install ikiwiki and use it with git. If you look at ikiwiki’s Nix expression, you’ll see that git support is disabled by default. How does one enable it?

The documentation on this can be hard to find, but it does exist1. The gist of it is to create the file ~/.nixpkgs/config.nix and override the settings there. Here’s how I enabled ikiwiki’s git support:

{
    packageOverrides = pkgs: with pkgs; {
        ikiwiki = ikiwiki.override {
            gitSupport = true;
        };
    };
}

Now you can install ikiwiki with nix-env -i ikiwiki and git will be pulled in.


  1. Mostly you’ll find mentions about a file called configuration.nix, but as far as I can tell, that only applies if you’re using NixOS. ↩︎


Comments or questions? Send me an e-mail.


Want to get these articles to your inbox? Subscribe to the newsletter: