NixOS / nixos-homepage

Sources for nixos.org
https://nixos.org
302 stars 315 forks source link

How Nix Works: the example nix-shell '<nixpkgs>' -A pan does not even configure #844

Closed rldp closed 2 years ago

rldp commented 2 years ago

on my learning path, I try the examples as I come across them.

In Learn / How Nix Works, under "Managing build environments", the example with the pan newsreader does not actually work as presented: it fails on the configure step.

After running

$ nix-shell '<nixpkgs>' -A pan
[nix-shell:~/how-nix-works-pan/pan-0.146]$ tar xf $src
[nix-shell:~/how-nix-works-pan/pan-0.146]$ ./configure

I get the error

...
checking for GTKSPELL... no
no
checking pkg-config is at least version 0.7... yes
checking for GTK+ - version >= 2.16.0... Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
no
*** Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GTK+ is incorrectly installed.

Looking at PKG_CONFIG_PATH, the only gtk+ present is

/nix/store/dsvwivybx5xnw4rhf3k3kgr5g35ylgn1-gtk+3-3.24.33-dev/lib/pkgconfig

According to the pan default.nix, it should use gtk+3, so I don't understand what is happening here.

nrdxp commented 2 years ago

so nix-shell '<nixpkgs>' is a special syntax, particularly the <> is telling nix to look in the special NIX_PATH env var for an entry called nixpkgs and evaluate the nix expression located at that path (by default, it looks for a default.nix if pointing at a directory). The -A something telling Nix to evaluate the attribute something (assuming the given expression is an attribute set).

What is happening is that the <nixpkgs> argument here on your local system is probably older that what is in the nixpkgs you linked and still using gtk 2 for the pan package. You can easily confirm this by exploring that path on your system.

rldp commented 2 years ago

thanks for the explanation (who doesn't like a "special syntax"!).

So I looked at my $NIX_PATH. It has a nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos.

I then compared pkgs/applications/networking/newsreaders/pan/default.nix with the one at https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/applications/networking/newsreaders/pan/default.nix, and find no difference.

So the mystery of my error remains.

But mostly, I feel some disappointment over the "broken" promise. Quoting from the web page: "the following command gets all dependencies of the Pan newsreader, as described by its Nix expression" and "Nix packages are reproducible and have complete dependency specifications".

Now either it works, or it doesn't. As you explained, "terms and conditions apply", but the page shows no such caveats. If the command "nix-shell '' -A pan" has preconditions, those should be specified too, to avoid confusion over an unexpected result.