How do I install a package from a derivation?

Hello! I am trying to install a particular version of the ‘gummy’ package (I have some scripts that rely on new features and the Nixpkgs version is too old). There is a pull request that could update it, but it’s been largely ignored for months by the package maintainer, so I’m looking for a short-term quick (local) and simple/easy solution until that gets fixed.

I’m thinking that the easiest way to do it is to use the derivation from the pull request, which is can be found here.

I don’t have a lot of experience with Nix right now (I got NixOS up and running with a template and a few basic options), so I don’t know how to do this. Please help me install this package. I don’t care if it’s not the “right” way to do it, if it’s imperative, impure etc - I’ll learn the language and redo it the right way if necessary, but now I have to get this thing working. Thank you!

For context, if necessary, this is my current NixOS configuration.

If you copied the default.nix from the PR you can install it by putting (pkgs.callPackage ./path/to/default.nix {}) (or just . instead of default.nix) in NixOS’ environment.systemPackages or Home Manager’s home.packages.

1 Like

I just tried that and I get the following error messages:

error:
       … while calling the 'head' builtin

         at /nix/store/3kwj19dbdfxnjbcns4hw307ylhz3wgrm-source/lib/attrsets.nix:1541:11:

         1540|         || pred here (elemAt values 1) (head values) then
         1541|           head values
             |           ^
         1542|         else

       … while evaluating the attribute 'value'

         at /nix/store/3kwj19dbdfxnjbcns4hw307ylhz3wgrm-source/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: getting status of '/nix/store/rq8zsd36v1rzrfbvadlqqmlsgmphz63x-source/hosts/hermes/gummy.nix': No such file or directory

Are you using Flakes? If so you will need to git add /path/to/gummy.nix first.

That fixed it! Thank you! I forgot that it was necessary to do that when using flakes.

1 Like