NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.45k stars 1.44k forks source link

error: evaluation of cached failed attribute 'packages.x86_64-linux' unexpectedly succeeded #10947

Closed oxalica closed 7 hours ago

oxalica commented 1 week ago

Describe the bug

Evaluation failures from flakes are incorrectly cached and reused even after config flag change (eg. whether to allow IFD).

Steps To Reproduce

  1. rm -r ~/.cache/nix/eval-cache-v5

  2. nix shell github:NixOS/nixfmt/c67a7b65906bd2432730929bd0e4957659c95b8e --no-allow-import-from-derivation, and it fails. This is expected.

    [..]
      error: cannot build '/nix/store/q3ga5hfdbnysydlbakrn74vmdq2x4p5p-cabal2nix-nixfmt.drv^out' during evaluation because the option 'allow-import-from-derivation' is disabled
  3. nix shell github:NixOS/nixfmt/c67a7b65906bd2432730929bd0e4957659c95b8e --allow-import-from-derivation but it fails immediately as below, which is unexpected.

    error: evaluation of cached failed attribute 'packages.x86_64-linux' unexpectedly succeeded
  4. Clean the eval-cache as (1) and run (4) again. It evaluates and builds the derivation successfully.

Expected behavior

The second eval with --allow-import-from-derivation should re-evaluate that attribute and build that derivation.

nix-env --version output

nix-env (Nix) 2.23.0

Additional context

In practice, I'm setting allow-import-from-derivation = false in /etc/nix/nix.conf instead of passing through arguments. So I only know it requires IFD after the first invocation, then I explicitly allow it temporarily through arguments but got this issue.

I don't know anyway to workaround it except dropping all eval-cache via rm -r ~/.cache/nix/eval-cache-v5.

My nix.conf: ``` # WARNING: this file is generated from the nix.* options in # your NixOS configuration, typically # /etc/nixos/configuration.nix. Do not edit it! allow-import-from-derivation = false allowed-users = * auto-allocate-uids = true auto-optimise-store = true builders = connect-timeout = 10 cores = 14 download-attempts = 3 experimental-features = auto-allocate-uids cgroups nix-command flakes ca-derivations flake-registry = max-jobs = auto nix-path = nixpkgs=/nix/store/xfpiyfgf6y30fxk5ngv0cjn474qfr3sj-source require-sigs = true sandbox = true sandbox-fallback = false stalled-download-timeout = 10 substituters = https://cache.nixos.org/ system-features = nixos-test benchmark big-parallel kvm trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= trusted-substituters = trusted-users = root @wheel use-cgroups = true extra-platforms = riscv64-linux i686-linux extra-sandbox-paths = /run/binfmt /nix/store/6vp96151s5s98hd9d6p56k18f2c73dd5-qemu-riscv64-binfmt-P-x86_64-unknown-linux-musl ```

Priorities

Add :+1: to issues you find important.

roberth commented 2 days ago

10992 will prevent this, but it does not clear existing bad entries.

If you encounter this after updating to a version that includes the fix, you may need to clear the cache a final time. As you wrote:

rm -r ~/.cache/nix/eval-cache-v5