nixos: create 'modules/nixos' folder
Let's consolidate all modules under one path, so that NixOS, home-manager, and nix-darwin (if I ever end up using it down the line) would go under the same folder.
This commit is contained in:
parent
b52e56ed08
commit
c856933803
74 changed files with 1 additions and 1 deletions
24
modules/nixos/secrets/default.nix
Normal file
24
modules/nixos/secrets/default.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{ config, inputs, lib, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.agenix.nixosModules.age
|
||||
];
|
||||
|
||||
config.age = {
|
||||
secrets =
|
||||
let
|
||||
toName = lib.removeSuffix ".age";
|
||||
userExists = u: builtins.hasAttr u config.users.users;
|
||||
# Only set the user if it exists, to avoid warnings
|
||||
userIfExists = u: if userExists u then u else "root";
|
||||
toSecret = name: { owner ? "root", ... }: {
|
||||
file = ./. + "/${name}";
|
||||
owner = lib.mkDefault (userIfExists owner);
|
||||
};
|
||||
convertSecrets = n: v: lib.nameValuePair (toName n) (toSecret n v);
|
||||
secrets = import ./secrets.nix;
|
||||
in
|
||||
lib.mapAttrs' convertSecrets secrets;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue