Skip to content

New crash when using --flake with flake not at git root #534

@katrinafyi

Description

@katrinafyi

I was trying to use the testpkgs as a minimal example for another bug with --flake. It turns out that the latest main has regressed the ability to update flakes which are not at the git root? Idk if this was intentional, but I thought I'd report it anyway.

As a demo repo, I'm using a fork of nix-update with an extra package added exposed through its testpkgs flake.nix.

git clone git@github.com:rina-forks/nix-update.git
cd nix-update
git checkout 4285fda3779e6e0104dcaf9b6272a763a55fbf5e

# this works:
nix run github:mic92/nix-update/v1.14.0#nix-update -- --flake -f ./tests/testpkgs --commit  github      

git reset --hard 4285fda3779e6e0104dcaf9b6272a763a55fbf5e

# this has an evaluation failure:
nix run github:mic92/nix-update/3ea1cb1a92b801dea7419505c918116b5ef0fd49#nix-update -- --flake -f ./tests/testpkgs/ --commit  github

nix error in last command:

error:
       … while evaluating attribute 'filename'
         at /nix/store/57vc3ix1nxdfjng29n2897jsy9ir7vrz-nix-update-v1.14.0/lib/python3.13/site-packages/nix_update/eval.nix:112:3:
          111|   inherit raw_version_position;
          112|   filename = position.file;
             |   ^
          113|   line = position.line;

       … while evaluating a branch condition
         at /nix/store/57vc3ix1nxdfjng29n2897jsy9ir7vrz-nix-update-v1.14.0/lib/python3.13/site-packages/nix_update/eval.nix:99:10:
           98|       raw_version_position
           99|     else if (builtins.unsafeGetAttrPos "src" pkg) != null then
             |          ^
          100|       sanitizePosition (builtins.unsafeGetAttrPos "src" pkg)

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: expected a set but found null: null

from what i can tell, it is using the flake at the git root rather than the specified flake in the subfolder. you can see this because trying to update nix-update does find the package and reports "Could not find a url in the derivations src attribute".

old instantiate command (succeeds):

$ nix-instantiate --eval --json --strict /nix/store/i75ksl15h4jl6lrxgrrhpqzyqg9s3qcd-nix-update-v1.14.0/lib/python3.13/site-packages/nix_update/eval.nix --argstr importPath /home/rina/progs/nix-update/tests/testpkgs --argstr attribute '["github"]' --arg isFlake true --arg sanitizePositions true

new instantiate comand (fails):

$ nix-instantiate --eval --json --strict /nix/store/57vc3ix1nxdfjng29n2897jsy9ir7vrz-nix-update-v1.14.0/lib/python3.13/site-packages/nix_update/eval.nix --argstr importPath /home/rina/progs/nix-update/tests/testpkgs --argstr attribute '["github"]' --arg isFlake true --arg sanitizePositions true --argstr flakeImportPath /nix/store/r426ydgp7ps8wid66r8zylxdls06w6jw-source

Most likely related to: #522

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions