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

nix flake check fails #1097

Closed
purefn opened this issue Apr 22, 2021 · 8 comments
Closed

nix flake check fails #1097

purefn opened this issue Apr 22, 2021 · 8 comments
Labels

Comments

@purefn
Copy link
Contributor

purefn commented Apr 22, 2021

After following the directions in the docs, I tried running nix flake check on my Linux machine. It fails, saying a x86_64-darwin is required. When I try and run it on macOS, I get the opposite, x86_64-linux is required. I assumed this has to do with IFD and maybe materialization would help. But it did not, it failed with the same errors.

Are there any tricks to making this work?

@jbgi
Copy link
Contributor

jbgi commented Apr 23, 2021

yeah, it is annoying. upstream issue: NixOS/nix#4265

one hacky "workaround" could be to wrap nix in the nix shell:

utils.lib.eachSystem (import ./supported-systems.nix) (system: {
  nixWapped = writeShellScriptBin "nix" ''
    # Temporary override `supported-systems.nix` original content to be able to use `nix flake show|check` on dev machines (workaround for https://github.com/NixOS/nix/issues/4265)'
    echo '[ "${system}" ]' > ./supported-systems.nix
    function atexit() {
        git restore --staged --worktree ./supported-systems.nix
    }
    trap atexit EXIT
    ${nixFlakes}/bin/nix "$@"
  '';
  devShell = ... {
     buildInputs = [nixWapped];
   };
})

jbgi added a commit to IntersectMBO/cardano-node that referenced this issue Apr 23, 2021
 and use rewrite-static from iohk-nix
@ParetoOptimalDev
Copy link

@jbgi Should that be prepended with checks = like:

checks = utils.lib.eachSystem (import ./supported-systems.nix) (system: {
  nixWapped = writeShellScriptBin "nix" ''
    # Temporary override `supported-systems.nix` original content to be able to use `nix flake show|check` on dev machines (workaround for https://github.com/NixOS/nix/issues/4265)'
    echo '[ "${system}" ]' > ./supported-systems.nix
    function atexit() {
        git restore --staged --worktree ./supported-systems.nix
    }
    trap atexit EXIT
    ${nixFlakes}/bin/nix "$@"
  '';
  devShell = ... {
     buildInputs = [nixWapped];
   };
})

I see the current code used in cardano-node is:

         checks = flattenTree (collectChecks' projectPackages) //
            # Linux only checks:
            (optionalAttrs hostPlatform.isLinux (
              prefixNamesWith "nixosTests/" (mapAttrs (_: v: v.${system} or v) nixosTests)
            ))
            # checks run on default system only;
            // (optionalAttrs (system == defaultSystem) {
            hlint = pkgs.callPackage pkgs.hlintCheck {
              inherit (project.args) src;
            };
          });

Is that a better workaround for some reason?

@ParetoOptimalDev
Copy link

ParetoOptimalDev commented Sep 21, 2022

Actually every workaround I'm trying gives me the same failure using nix (Nix) 2.11.0:

$ git clone https://github.com/input-output-hk/cardano-node.git && cd cardano-node/ && nix flake check
... snip ...
error: cannot build '/nix/store/azr2hsfb2876a5ihwm41dq17p3j6wzcd-cardano-node-plan-to-nix-pkgs.drv' during evaluation because the option 'allow-import-from-derivation' is disabled
(use '--show-trace' to show detailed location information)

Or even using nix (Nix) 2.12.0pre20220921_f704c27:

git clone https://github.com/input-output-hk/cardano-node.git && cd cardano-node/ && nix run github:NixOS/nix flake check
... snip ...
error: cannot build '/nix/store/azr2hsfb2876a5ihwm41dq17p3j6wzcd-cardano-node-plan-to-nix-pkgs.drv' during evaluation because the option 'allow-import-from-derivation' is disabled
(use '--show-trace' to show detailed location information)

@hamishmack
Copy link
Collaborator

Try:

nix run github:NixOS/nix flake check -- --allow-import-from-derivation

@ParetoOptimalDev
Copy link

This works, but I don't think it can fix my actual immediate problem of getting haskell.nix to work with eu.nixbuild.net.I accidentally created an XY problem here by trying to simplify my problem for potential askers :/

I'll create a new issue describing my full problem and giving more context.

@peterbecich
Copy link
Contributor

I think the haskell.nix Flake in cicero-pipe has a solution to this issue: https://github.com/input-output-hk/cicero-pipe
The key may be the materialization: https://github.com/input-output-hk/cicero-pipe/tree/master/nix/materialized

I am trying to copy the solution from cicero-pipe: #1825

@peterbecich
Copy link
Contributor

A solution for nix flake show was recently merged: NixOS/nix#6988

The same issue for nix flake check on Flakes using IFD is discussed here: NixOS/nix#4265

I have copied the show PR to attempt to fix nix flake check: NixOS/nix#7759

@stale
Copy link

stale bot commented Jun 6, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 6, 2023
@stale stale bot closed this as completed Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants