Skip to content
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

Running nix flake show fails to evaluate on x86_64-linux #1154

Closed
Lehmanator opened this issue Feb 23, 2024 · 10 comments · Fixed by #1817
Closed

Running nix flake show fails to evaluate on x86_64-linux #1154

Lehmanator opened this issue Feb 23, 2024 · 10 comments · Fixed by #1817
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Lehmanator
Copy link

Evaluating flake outputs fails on x86_64-linux. Seems to want to a aarch64-darwin system. nix flake show should successfully evaluate independent of system type.

Seems something is referencing perSystem.aarch64-darwin.packages when evaluating on x86_64-linux.

$ nix flake show github:nix-community/nixvim`

error:
       … while calling anonymous lambda

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/types.nix:593:29:

          592|       merge = loc: defs:
          593|         zipAttrsWith (name: defs:
             |                             ^
          594|           let merged = mergeDefinitions (loc ++ [name]) elemType defs;

       … while calling anonymous lambda

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:824:28:

          823|         # Process mkMerge and mkIf properties.
          824|         defs' = concatMap (m:
             |                            ^
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/5yhqhsl8x9xmhsy3ql8hi05c3zbnxx2x-source/modules/transposition.nix':

       … from call site

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:825:137:

          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … while calling anonymous lambda

         at /nix/store/5yhqhsl8x9xmhsy3ql8hi05c3zbnxx2x-source/modules/transposition.nix:104:22:

          103|           mapAttrs
          104|             (system: v: v.${attrName} or (
             |                      ^
          105|               abort ''

       … while calling 'g'

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/attrsets.nix:739:19:

          738|           g =
          739|             name: value:
             |                   ^
          740|             if isAttrs value && cond value

       … from call site

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/attrsets.nix:742:20:

          741|               then recurse (path ++ [name]) value
          742|               else f (path ++ [name]) value;
             |                    ^
          743|         in mapAttrs g;

       … while calling anonymous lambda

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:242:72:

          241|           # For definitions that have an associated option
          242|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          243|

       … while evaluating the option `perSystem.aarch64-darwin.checks':

       … while calling anonymous lambda

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:824:28:

          823|         # Process mkMerge and mkIf properties.
          824|         defs' = concatMap (m:
             |                            ^
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/by7vnhmzbs67gb7pm0hazl8s9qgiviqb-source/flake-modules/packages.nix, via option perSystem':

       … from call site

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:825:137:

          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … while calling 'g'

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/attrsets.nix:739:19:

          738|           g =
          739|             name: value:
             |                   ^
          740|             if isAttrs value && cond value

       … from call site

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/attrsets.nix:742:20:

          741|               then recurse (path ++ [name]) value
          742|               else f (path ++ [name]) value;
             |                    ^
          743|         in mapAttrs g;

       … while calling anonymous lambda

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:242:72:

          241|           # For definitions that have an associated option
          242|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          243|

       … while evaluating the option `perSystem.aarch64-darwin.packages':

       … while calling anonymous lambda

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:824:28:

          823|         # Process mkMerge and mkIf properties.
          824|         defs' = concatMap (m:
             |                            ^
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/by7vnhmzbs67gb7pm0hazl8s9qgiviqb-source/flake-modules/packages.nix, via option perSystem':

       … from call site

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:825:137:

          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … from call site

         at /nix/store/by7vnhmzbs67gb7pm0hazl8s9qgiviqb-source/flake-modules/packages.nix:9:16:

            8|   }: {
            9|     packages = import ../docs {
             |                ^
           10|       inherit rawModules pkgs helpers;

       … while calling anonymous lambda

         at /nix/store/by7vnhmzbs67gb7pm0hazl8s9qgiviqb-source/docs/default.nix:1:1:

            1| {
             | ^
            2|   rawModules,

       error: a 'aarch64-darwin' with features {} is required to build '/nix/store/z88kmrcswk7j13lxnkydld1xnifprvsm-nixpkgs-nixvim-doc.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, ca-derivations, kvm, nixos-test, recursive-nix, uid-range}

@traxys
Copy link
Member

traxys commented Mar 13, 2024

Unfortunately the problem is now even worse, because an nixvim update introduced an import from derivation case due to our handling of the documentation generation. See NixOS/nix#3920

@viniciuspalma
Copy link

Having some similar issue on M1 MacBook

nix-darwin on  main [!+] took 44s 
› nix run nix-darwin -- switch --flake ~/.config/nix-darwin 
warning: Git tree '/Users/vini/.config/nix-darwin' is dirty
building the system configuration...
warning: Git tree '/Users/vini/.config/nix-darwin' is dirty
trace: warning: vini profile: The option `plugins.gitsigns.signs.change.text' defined in `/nix/store/0wrvrf0mclk77mizi0chgyb9nkrcs695-source/home/nvim/plugins' has been renamed to `plugins.gitsigns.settings.signs.change.text'.
trace: warning: vini profile: The option `plugins.gitsigns.signs.add.text' defined in `/nix/store/0wrvrf0mclk77mizi0chgyb9nkrcs695-source/home/nvim/plugins' has been renamed to `plugins.gitsigns.settings.signs.add.text'.
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'darwin-system-24.05.20240327.a5f24ad+darwin4.bcc8afd'
         whose name attribute is located at /nix/store/r7f66cq2dqrysk6080r39sbbivj0fagq-source/pkgs/stdenv/generic/make-derivation.nix:331:7

       … while evaluating attribute 'activationScript' of derivation 'darwin-system-24.05.20240327.a5f24ad+darwin4.bcc8afd'
         at /nix/store/4f2vbp0y3qd20qvx2fm03nyb37r5121n-source/modules/system/default.nix:95:7:
           94|
           95|       activationScript = cfg.activationScripts.script.text;
             |       ^
           96|       activationUserScript = cfg.activationScripts.userScript.text;

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

       error: a 'aarch64-darwin' with features {} is required to build '/nix/store/583s25cym7llb5chjil3g2ms9i1abxsv-nixpkgs-nixvim-doc.drv', but I am a 'x86_64-darwin' with features {apple-virt, benchmark, big-parallel, nixos-test}

nix-darwin on  main [!+] took 26s

@GaetanLepage
Copy link
Member

Does this issue just amounts to us using IFD (import from derivation) in our flake or is it another issue (thus more concerning) ?

@traxys
Copy link
Member

traxys commented May 20, 2024

Not 100% sure, I can't reproduce

@MattSturgeon
Copy link
Member

Can we workaround the IFD issue by putting the patched nixpkgs derivation into a dedicated flake and importing that as an input in the main flake?

I'm pretty sure we could have a separate flake within our repo, as long as it's in its own directory.

@GaetanLepage
Copy link
Member

Can we workaround the IFD issue by putting the patched nixpkgs derivation into a dedicated flake and importing that as an input in the main flake?

I'm pretty sure we could have a separate flake within our repo, as long as it's in its own directory.

From what I remember, there is not a single cause for IFD but several... One of them is the docs and the other one is the template. I could be wrong though, I have made those experiments a while ago.

@notthebee
Copy link

The issue breaks cross-platform deployments with deploy-rs (aarch64-darwin > x86_64-linux) – even with --remote-build and --skip-checks flags set:

 deploy ".?submodules=1#spencer" -s --remote-build                                                                                                                                                                     
🚀 ℹ️ [deploy] [INFO] Evaluating flake in .?submodules=1
error:
~~~
       error: a 'x86_64-linux' with features {} is required to build '/nix/store/4gsqcrl8d47xklc9wx4550qfw5vb403h-nixpkgs-nixvim-doc.drv', but I am a 'aarch64-darwin' with features {apple-virt, benchmark, big-parallel, nixos-test}
🚀 ❌ [deploy] [ERROR] Failed to evaluate deployment data: Evaluation resulted in a bad exit code: Some(1)

Is there any way to circumvent the issue until a more long-term fix is created?

@MattSturgeon
Copy link
Member

MattSturgeon commented Jun 7, 2024

#1637 removed the main IFD we were blocked on, so this is no longer a "won't fix".

There's one* IFD left in our wrapper checks:

checks =
{
home-manager-module =
(import ../tests/modules/hm.nix {
inherit pkgs;
inherit (inputs) home-manager;
nixvim = self;
}).activationPackage;
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
nixos-module =
(import ../tests/modules/nixos.nix {
inherit system;
inherit (inputs) nixpkgs;
nixvim = self;
}).config.system.build.toplevel;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin-module =
(import ../tests/modules/darwin.nix {
inherit system;
inherit (inputs) nix-darwin;
nixvim = self;
}).system;
};

Removing that checks attribute is enough to fix this issue, although we'll have to come up with a better solution where we can still test what we need to without an IFD in the flake evaluation.

These tests were introduced in #901, #907, & #909.

* ok, there's three. But they're grouped together and basically the same thing...

@MattSturgeon MattSturgeon added bug Something isn't working help wanted Extra attention is needed labels Jun 7, 2024
@notthebee
Copy link

Removing the check does fix the nix flake show output. Unfortunately though, deployer seems to hang up on something else:

error: a 'x86_64-linux' with features {} is required to build '/nix/store/dknd53ikkkjvk5jgw0hcwmby9ddpj9v1-init.lua.drv', but I am a 'aarch64-darwin' with features {apple-virt, benchmark, big-parallel, nixos-test}

Should I open a separate issue for this?

@MattSturgeon
Copy link
Member

@notthebee yes please. It's better if this issue is focused on one bug rather than two 👍

@mergify mergify bot closed this as completed in 8fbcfcb Jul 5, 2024
nfelber pushed a commit to nfelber/nixvim that referenced this issue Jul 19, 2024
…efinition

If we access the asserts outside the derivation arguments, and inside
the code that _creates_ the derivation then we observe IFD in `nix flake
show`.

This commit fixes it, and allows `nix flake show` to work!

Fixes nix-community#1154
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants