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
/nix/store/34v5lm3pbbcvx3gabw2r0gi6khm8qlzz-curl-7.68.0/share/zsh/site-functions/_curl
/nix/store/51iw8v0jgddppdcr34g3hlq5j1j56r3r-curl-7.68.0/share/zsh/site-functions/_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)
/nix/store/fcjz6ganvyz3q1ayav32rk0qdixa8ydr-curl-7.68.0-bin
└── bin
    └── curl

1 directory, 1 file

Not here, but . . .

λ brh nixpkgs →  tree $(nix-build -A curl.out)
/nix/store/5na95ifvbvivp961argc3fhayldd4m3l-curl-7.68.0
├── lib
│   ├── libcurl.la
│   ├── libcurl.so -> libcurl.so.4.6.0
│   ├── libcurl.so.4 -> libcurl.so.4.6.0
│   └── libcurl.so.4.6.0
└── share
    ├── fish
    │   └── vendor_completions.d
    │       └── curl.fish
    └── 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.