NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.97k stars 1.47k forks source link

Confusing behavior when installing part of a split-output derivation #3538

Open bdesham opened 4 years ago

bdesham commented 4 years ago

I’d like to install Curl from nixpkgs and I’d like its zsh completion script to be included. (Zsh comes with an extremely simple completion script for Curl, but I’d like to use the more full-featured one that is shipped with Curl itself.) I can install the Curl binary with

nix-env -i -A nixpkgs.curl

but this does not install the “big” completion script, which is hundreds of lines long:

$ find -L ~/.nix-profile/share -name _curl -exec wc -l '{}' ';'
7 /Users/bdesham/.nix-profile/share/zsh/5.8/functions/_curl

I asked a question about this on the NixOS Discourse and a poster suggested that, since Curl is a split-output derivation, I needed to install the “out” derivation. So I tried to uninstall what I had installed before and install only curl.out:

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

But it seems that (1) the completion script is still not installed, and (2) the Curl binary still is installed:

$ find -L ~/.nix-profile/share -name _curl -exec wc -l '{}' ';'
7 /Users/bdesham/.nix-profile/share/zsh/5.8/functions/_curl
$ find -L ~/.nix-profile/bin -name curl
/Users/bdesham/.nix-profile/bin/curl

This makes it seem as if, when I ask for nixpkgs.curl.out, nix-env is really just giving me nixpkgs.curl. So I have two questions:

  1. When I install nixpkgs.curl.out, is nix-env really installing the same things as if I had asked for nixpkgs.curl? If so, this seems like a bug, or at least a confusing design; would it be appropriate to issue a warning somewhere?
  2. How can I install Curl and its zsh completion script?

Thanks for reading!

(I think this is a bug/misunderstanding in Nix, not in Nixpkgs, but if I’m wrong I’d be happy to open an issue in the Nixpkgs tracker instead.)

System information

nixos-discourse commented 4 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-can-i-install-curl-with-its-zsh-completion-script/5902/4

doronbehar commented 4 years ago

I experience this issue on NixOS as well, with curlFull installed globally via environment.systemPacakges. It seems that when a derivation has multiple outputs, this causes some paths not to link. I had a similar issue with Info files of GNU make:

https://github.com/NixOS/nixpkgs/issues/65325

I think this is fixable if you'd patch curl to use a pathsToLink attribute or specifically for your case, with an overlay such as:

https://github.com/NixOS/nixpkgs/issues/65325#issuecomment-524345947

But the big issue is that Nix & Nixpkgs are not coordinated in this topic, just as you pointed out in your 2 questions. When nix-build runs, it takes all outputs, but nix-env's behavior is just not clear.

If you are interested in further opinions: https://discourse.nixos.org/t/could-weve-implemented-multi-output-packages-better/6597

nixos-discourse commented 4 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/could-weve-implemented-multi-output-packages-better/6597/5

bdesham commented 4 years ago

Thanks for the links, @doronbehar!

It seems that what I reported above is definitely a bug in nix-env, inasmuch as it accepts inputs like

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

but then installs something else instead. If this invocation won’t install the out output, it should immediately produce an error instead of silently doing something else 😕

It seems that nixpkgs PR 76794 would at least document this behavior, but it hasn’t seen any activity in four months.

nixos-discourse commented 4 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/missing-man-pages/4680/7

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

doronbehar commented 3 years ago

Still an issue.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

bdesham commented 3 years ago

I believe this is still an issue.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info