buildnixnixoswaf

Nix: Building `waf` produces a file, but I seem to need a folder


I've cloned the nixpkgs repo. From the top of that repo, I can run nix-build -A waf to build waf, and nix-env -f . -iA waf to make waf part of my user environment. Neither complains -- but afterward I am still unable to call waf:

[jeff@jbb-dell:~/nix/nixpkgs]$ waf
waf: command not found

[jeff@jbb-dell:~/nix/nixpkgs]$ 

Most packages, when I build them using nix-build -A, produce a symlink called result that goes to a folder containing the executable in question. Strangely, though, in waf's case the symlink is to a file, not a folder.

I'm running NixOS. If I add waf to environment.systemPackages in my configuration, upon building I get an error that seems to be a result of the strangeness described in the previous paragraph:

[jeff@jbb-dell:~/nix/jbb-config]$ sudo nixos-rebuild switch
building Nix...
building the system configuration...
these derivations will be built:
  /nix/store/s618gllra3g2vn62c92advg9ks2swkz1-system-path.drv
  /nix/store/gpph3adrgn949mikfvkwld86flshdbvq-unit-polkit.service.drv
  /nix/store/i7xql7889ank54fnhd16zk4z79l1ix88-unit-systemd-fsck-.service.drv
  /nix/store/dv9p4fsrqn1fwdvy9scyc7g9422wvm7c-dbus-1.drv
  /nix/store/y730jf9s9nrzmkf55i01nlwinw5gxpsp-unit-dbus.service.drv
  /nix/store/4wjan71p2di7lscnscdfhp55j49dcymx-system-units.drv
  /nix/store/qrzwrpsz0hh5gzaxic6ww8mnwl03zwil-unit-dbus.service.drv
  /nix/store/lhq0s9s5v3sqvjx6mqlyqj6hf4kv38sf-user-units.drv
  /nix/store/hk5wbmf4dpna3dn0h0q1balj3482l6xd-etc.drv
  /nix/store/yj3lfyv5sbp751xzy9jdw1d06n9gdiin-nixos-system-jbb-dell-19.09.1889.692a8cabbcc.drv
building '/nix/store/s618gllra3g2vn62c92advg9ks2swkz1-system-path.drv'...
The store path /nix/store/f1ylicjswpfx1wbvxapsnwy987qnlxl6-waf-2.0.18 is a file and can't be merged into an environment us ing pkgs.buildEnv! at /nix/store/kncarzyhspzsplkcmmyiqg2cavrwr373-builder.pl line 96.
builder for '/nix/store/s618gllra3g2vn62c92advg9ks2swkz1-system-path.drv' failed with exit code 2
cannot build derivation '/nix/store/yj3lfyv5sbp751xzy9jdw1d06n9gdiin-nixos-system-jbb-dell-19.09.1889.692a8cabbcc.drv': 1 dependencies couldn't be built
error: build of '/nix/store/yj3lfyv5sbp751xzy9jdw1d06n9gdiin-nixos-system-jbb-dell-19.09.1889.692a8cabbcc.drv' failed

[jeff@jbb-dell:~/nix/jbb-config]$ 

Solution

  • This looks like an implementation error to me. waf, as a top-level Nixpkgs package, should put its binary in $out/bin. I've checked for usages of waf in nixpkgs and it seems to be used inside derivations only via wafHook.

    If you only need waf inside a derivation, I recommend going with wafHook, following the example of other packages. If you need to install it in your user profile, ideally you can send a PR to make waf a proper package or you can work around it with a custom derivation.