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

Import lib in secrets.nix #310

Open
RatCornu opened this issue Jan 26, 2025 · 1 comment
Open

Import lib in secrets.nix #310

RatCornu opened this issue Jan 26, 2025 · 1 comment

Comments

@RatCornu
Copy link

Hello! I would like to import lib variable in the secrets.nix file to be able to declare more generic rules in secret configuration. However I could not find a workaround to do it: would it be possible to add the possibility to import lib or pkgs in the configuration file?

Thanks for your work!

@wyyllou
Copy link

wyyllou commented Mar 12, 2025

You can do it like this, its not the most pure thing but it works. Theres probably a more complicated way with builtins.getFlake if you want to use the exact nixpkgs commit of your flake in the secrets.nix, instead of the one in your nix search path, but this should be fine.

# secrets.nix
let
  inherit (import <nixpkgs> { }) lib;
  system = "ssh key...";
in
{
   "example.age".publicKeys = lib.singleton system; # example
}

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

2 participants