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

Carry over --impure from initial nix run to nixinate evaluation #54

Open
rschardt opened this issue Jun 27, 2024 · 0 comments
Open

Carry over --impure from initial nix run to nixinate evaluation #54

rschardt opened this issue Jun 27, 2024 · 0 comments

Comments

@rschardt
Copy link

rschardt commented Jun 27, 2024

I have some scripts which require --impure mode to be enabled.

        {
          _module.args.nixinate = {
            host = "host";
            sshUser = "root";
            buildOn = "local";
            substituteOnTarget = false;
            hermetic = false;
            nixOptions = [ "--impure" ];
          };
        }
  1. Option: I would expect that 'nix run .#apps.nixinate.machine' now runs as impure without using the --impure option explicitly :
error:
       … in the left operand of the update (//) operator

         at /nix/store/7gzgi8zsnh06pv9cphb30yv9h1pyn4nk-source/flake.nix:84:20:

           83|                    )
           84|                    // nixpkgs.lib.genAttrs
             |                    ^
           85|                       (map (a: a + "-dry-run") validMachines)

       … while calling the 'listToAttrs' builtin

         at /nix/store/f0ddmw6s86y567yg06h5019z72szbzch-source/lib/attrsets.nix:1248:5:

         1247|     f:
         1248|     listToAttrs (map (n: nameValuePair n (f n)) names);
             |     ^
         1249|

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

       error: access to absolute path '/etc/hostname' is forbidden in pure eval mode (use '--impure' to override)

My script tries to read /etc/hostname therefore we ran into problems here.

  1. Option: However if we decide to run 'nix run .#apps.nixinate.machine --impure' we bypass the error.
  2. Option: Just running 'nix run .#apps.nixinate.machine --impure' without settings the nixOption still fails with the pure eval mode error.

So I guess arguments passed to nix run don't really carry over when nixosConfigurations are evaluated/built atleast.
Maybe there is a way to read arguments passed to nix run during evaluation and concat them with the maybe provided nixOptions options?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant