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

fix: add --strict nix-instantiate to support builtins.readFile #202

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

WillPower3309
Copy link
Contributor

@WillPower3309 WillPower3309 commented Sep 22, 2023

If a user has a secrets.nix that uses builtins.readFile to set the value of a key, as such:

let
  system = builtins.readFile ../hosts/server/ssh_host_ed25519_key.pub;

in
{
  "rootPassword.age".publicKeys = [ system ];
}

an error occurs:

❯ nix-instantiate --eval --json secrets.nix
error:
       … message for the trace

         at /home/will/Projects/nixos-config/secrets/secrets.nix:10:3:

            9| {
           10|   "rootPassword.age".publicKeys = system;
             |   ^
           11| }

       error: cannot convert a thunk to JSON

       at /home/will/Projects/nixos-config/secrets/secrets.nix:10:3:

            9| {
           10|   "rootPassword.age".publicKeys = system;
             |   ^
           11| }

adding --strict fixes this

@NobbZ
Copy link

NobbZ commented Sep 22, 2023

This would probably happen for any kind of doing "computation" in the bindings, not only for builtins.readFile.

Copy link
Owner

@ryantm ryantm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ryantm ryantm merged commit 1f677b3 into ryantm:main Sep 22, 2023
2 checks passed
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

Successfully merging this pull request may close these issues.

4 participants