Skip to content

Add layers to catching IFDs in nix flake show #13343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ulucs
Copy link
Contributor

@ulucs ulucs commented Jun 10, 2025

Motivation

Fixes #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 ulucs requested a review from edolstra as a code owner June 10, 2025 13:11
@github-actions github-actions bot added the new-cli Relating to the "nix" command label Jun 10, 2025
Copy link
Member

@Mic92 Mic92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a regression test here? ./tests/functional/flakes/show.sh

@soenkehahn
Copy link
Contributor

@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?

@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Jun 25, 2025
@ulucs
Copy link
Contributor Author

ulucs commented Jun 25, 2025

@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

@ulucs ulucs force-pushed the ulucs/push-tsvykuzmosxo branch from 7162d1e to 9f94f04 Compare June 25, 2025 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nix flake show shouldn't error in case of ifd creating flake outputs
3 participants