I’m really new to nix so a detailed explanation of the solution would be appreciated.

I’m trying to add rnix-lsp to my home config. The instructions on the github page simply state to run a nix-env command on a url to a tarball which I’m not sure what to do with.

I know about fetchTarball, but I can’t figure out how to use it in a way that works with home.packages. I’ve tried something like this:

home.packages = [
    (import (fetchTarball “https://github.com/nix-community/rnix-lsp/archive/master.tar.gz”) {}; ).defaultNix

But then I get an error about trying to call a set. Is there any way to do what I want to do?

The error specifically:

error: attempt to call something which is not a function but a set, at /home/izzylan/.config/nixpkgs/home.nix:33:9

I figured out the answer to this myself by diving into the source code:

import (fetchTarball “https://github.com/nix-community/rnix-lsp/archive/master.tar.gz”)

Why this works

We can see in home-environment.nix that home-manager expects that home.packages expects a type that's a list of types.package. This is defined in the nixpkgs module, so we can check types.nix to see how nix determines what is a "package". We can then find the definition for the package type and see that a package is either a derivation or a string containing a store path.

rnix-lsp is already a nix project and exports itself as a derivation in default.nix.1 Therefore, all we need to is download it as a tarball, and import it into our config. home-manager will then happily take the derivation, build it, and install it like any other package.

1 Technically it's defined as a flake in flake.nix and default.nix uses flake-compat to export it as a derivation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.