How can I install Curl with its zsh completion script?

I’m using Nix as a package manager on macOS. When I run nix-env -i -A nixpkgs.curl, the only Curl files that are “installed” in ~/.nix-profile are the binary and the man pages. I would like the zsh completion script (located in $out/share/zsh/site-functions) to be installed too. There are already several copies of this script in the Nix store, e.g.

$ find /nix/store/*-curl-7.68.0* -name _curl

How can I tell Nix that I want this path to be linked into my ~/.nix-profile?

Curl is a multiple-output derivation, so it seems like maybe I want to install the “out” output, but I’m not sure what that would look like using nix-env. I could add an override for curl to my config.nix if necessary.

If you run nix edit nixpkgs.curl, it’ll take you to the curl derivation file in your $EDITOR, which shows that curl is a split-output package with the following installable packages:

  outputs = [ "bin" "dev" "out" "man" "devdoc" ];

You can then take a look at them and see what each one has:

λ brh nixpkgs →  tree $(nix-build -A curl.bin)
└── bin
    └── curl

1 directory, 1 file

Not here, but . . .

λ brh nixpkgs →  tree $(nix-build -A curl.out)
├── lib
│   ├──
│   ├── ->
│   ├── ->
│   └──
└── share
    ├── fish
    │   └── vendor_completions.d
    │       └──
    └── zsh
        └── site-functions
            └── _curl

6 directories, 6 files

Has what you want! So just run nix-env -i nixpkgs.curl.out and it’ll also install the out package.

When you install a split-output package foo, it just takes the first output to save on disk space, which by convention is the bin output.

Thanks for the reply! I tried nix-env -i -A nixpkgs.curl.out (I had to add the -A flag) but I still don’t see those files linked into ~/.nix-profile/share. Oddly, even if I run

nix-env -e curl
nix-env -i -A nixpkgs.curl.out

the Curl binary is still linked in to ~/.nix-profile/bin but the files under ~/.nix-profile/share are not there. Is nix-env only pretending that it understands multiple-output derivations? :confused:

I opened a ticket about this in the “nix” repo.