Open ShamrockLee opened 1 year ago
Apparently the same underlying error can be reproduced using this simple devshell.toml
(after nix flake init -t github:numtide/devshell
):
[devshell]
packagesFrom = ["i3"]
Looks like the error is triggered by separateDebugInfo = true;
in the package; specifying the devshell configuration in Nix and using overrideAttrs
may be used as a workaround:
devshell.packagesFrom = [
(pkgs.i3.overrideAttrs { separateDebugInfo = false; })
];
Apparently the problem comes from https://github.com/NixOS/nixpkgs/blob/7c5f52e2bf743401ab9253bab048883d66ad357f/pkgs/stdenv/generic/make-derivation.nix#L282 — that code adds a path instead of a proper derivation to nativeBuildInputs
, which then shows up in the package attributes (the last one):
$ nix repl --extra-experimental-features repl-flake github:NixOS/nixpkgs/nixpkgs-unstable
nix-repl> legacyPackages.x86_64-linux.i3.nativeBuildInputs
[ «derivation /nix/store/9by54ylsfw1a617njnldvhn8dr5j01wx-pkg-config-wrapper-0.29.2.drv» «derivation /nix/store/97yalyh89bbizl1v8vimw2wzj523kxpy-make-shell-wrapper-hook.drv» «derivation /nix/store/pydn180r1ydq95qvpajqj4nqiz99zzk7-meson-1.3.2.drv» «derivation /nix/store/4risxx9frn02fraphwrb0jbcpcx78a0g-ninja-1.11.1.drv» «derivation /nix/store/6znlk8vzvs6p344kh139n864rl9rgw18-install-shell-files.drv» «derivation /nix/store/wp1k91z46bnkp1vg99r654km760ridj3-perl-5.38.2.drv» «derivation /nix/store/asni7p54vgbyjdrbl4jrmc96svk1yxj1-asciidoc-10.2.0.drv» «derivation /nix/store/1grx2q3s0k31cdawwdssanxpn0psjy8y-xmlto-0.0.28.drv» «derivation /nix/store/9ngb4s4qc7b1dlkpjdivvi8i4mdm3cas-docbook-xml-4.5.drv» «derivation /nix/store/hac09wcvx8i3xfvc646zdjjpnkf1hiad-docbook-xsl-nons-1.79.2.drv» «derivation /nix/store/fjn8b7x8gdz7hhav0qyvjr8yzmjaicsc-find-xml-catalogs-hook.drv» /nix/store/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source/pkgs/build-support/setup-hooks/separate-debug-info.sh ]
Maybe https://github.com/numtide/devshell/blob/5ddecd67edbd568ebe0a55905273e56cc82aabe3/modules/devshell.nix#L200-L205 needs to filter the attribute values instead of accepting everything.
However, the current implementation of devshell.packagesFrom
is not ideal even with a possible fix, because it gets only the direct build dependencies of the specified packages, but does not follow the chain of propagatedBuildInputs
and propagatedNativeBuildInputs
, therefore some build dependencies actually end up being unusable without their own dependencies. In theory, applying lib.misc.closePropagation
to the list of packages should solve that problem by bringing in all required dependencies recursively; however, because devshell
tries to build a single environment with all specified packages, it runs into conflicts like
error: collision between `/nix/store/5zv2bbd3y7s08qcnj6j7w39i26gqjg9b-xorgproto-2023.2/include/X11/extensions/XKBgeom.h' and `/nix/store/853h1w10rfpvhky02l8a2z07z21sqbhx-libX11-1.8.7-dev/include/X11/extensions/XKBgeom.h'
With the stock mkShell
such conflicts are not really a problem, because the conflicting packages don't get combined into a single environment (you get a long list of options in NIX_CFLAGS_COMPILE
and NIX_LDFLAGS
instead), therefore the conflicts are resolved silently (but one of those conflicting include files would end up shadowing the others).
Describe the bug
The
root
derivation inside Nixpkgs is the package of CERN ROOT, a C++-based data analysis framework.When using
devshell.flakeModule
and specifydevshells.root-devenv.devshell.packagesFrom = [ pkgs.root ];
, wherepkgs
is from the input of the function assigned toperSystem
flake-part attribute, the following error is triggeredTo Reproduce
Steps to reproduce the behavior:
Prepare
flake.nix
with the following contentflake.lock
with the following contentnix flake check path:.
and see error.nix develop path:. root-devenv
and see error.pkgs.root
withpkgs.hello
, and the error will disappear.Expected behavior
The above
flake.nix
andflake.lock
run without error, as if thepkgs.root
were replaced withpkgs.hello
.System information
nix-info -m
"x86_64-linux"
Linux 6.1.31, NixOS, 23.05 (Stoat), 23.05.20230604.e7603eb
yes
yes
nix-env (Nix) 2.15.0
/nix/store/yd0l7092ykql0k60fn1jxlqxl16wp4vn-source
Additional context