这是indexloc提供的服务,不要输入任何密码
Skip to content

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!

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