Add layers to catching IFDs in `nix flake show`
Motivation
Fixes https://github.com/NixOS/nix/issues/13335.
Context
Expands the scope of #12583; allowing recursion into "derivation containers" even when their attributes can't be evaluated due to an IFD, and then catches the IFD error when trying to visit those nodes.
Flake:
{
outputs = { nixpkgs, ... }:
let
system = "aarch64-linux";
pkgs = import nixpkgs { inherit system; };
in
{
packages.${system} =
(import (pkgs.writeText "nix-expr" "{}"));
checks.${system} = {
test = pkgs.hello;
};
};
}
Before:
error:
… while calling the 'import' builtin
at /nix/store/4rw0d5agbcz96rhjwkmgx5v3bpjnz8bh-source/build/flake.nix:9:10:
8| packages.${system} =
9| (import (pkgs.writeText "nix-expr" "{}"));
| ^
10| checks.${system} = {
… while realising the context of path '/nix/store/35006aqknvcnq3l5w4dryw1j851qng30-nix-expr'
error: cannot build '/nix/store/2m3x8phhksw5fl039d0dwv2hk2izapwm-nix-expr.drv^out' during evaluation because the option 'allow-import-from-derivation' is disabled
After:
git+file:///software/nix?dir=build
├───checks
│ └───aarch64-linux
│ └───test omitted (use '--all-systems' to show)
└───packages
└───aarch64-linux omitted due to use of import from derivation
@ulucs: Thanks a lot for working on this!
I tried this out (with the example from here) by running nix shell -L github:ulucs/nix/ulucs/push-tsvykuzmosxo#nix and that didn't work as advertised, nix flake show was still crashing. Do I have to also have the nix daemon running from this commit in order for it to work?
@soenkehahn yes, I had the daemon also running for the tests
I was also finally able to add the tests on top of the previous tests
Hello! The tests are added; but I think the message got lost because I also replied to someone else at the same time
Needs a rebase after the treewide reformat. Please refer to https://github.com/NixOS/nix/issues/13502 for how to handle that.
I'm not using git so that was a bit manual, but should be all good now
Hello! Are there any additional changes I should make in here?