refactor(modules): clean up folder structure
This commit is contained in:
parent
d8aa7f62b4
commit
03fca8b28b
12 changed files with 32 additions and 38 deletions
50
nix/modules/system/secrets.nix
Normal file
50
nix/modules/system/secrets.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.flake;
|
||||
inherit (builtins) readFile;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.strings) trim;
|
||||
inherit (cfg.admin) username pubkey;
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.default =
|
||||
{ config, ... }:
|
||||
{
|
||||
imports = [ inputs.sops-nix.nixosModules.sops ];
|
||||
config.sops.age.sshKeyPaths = [
|
||||
"/persist${config.users.defaultUserHome}/${username}/.ssh/id_ed25519"
|
||||
];
|
||||
};
|
||||
flake.modules.homeManager.default.persistDirs = [ ".config/sops/age" ];
|
||||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
files.files = [
|
||||
{
|
||||
path_ = ".sops.yaml";
|
||||
drv =
|
||||
pkgs.writeText ".sops.yaml" # yaml
|
||||
''
|
||||
keys:
|
||||
- &${username} ${trim (
|
||||
readFile "${
|
||||
pkgs.runCommand "" { } ''
|
||||
mkdir $out; echo ${pubkey} | ${getExe pkgs.ssh-to-age} > $out/agepubkey
|
||||
''
|
||||
}/agepubkey"
|
||||
)}
|
||||
creation_rules:
|
||||
- path_regex: \.(yaml)$
|
||||
key_groups:
|
||||
- age:
|
||||
- *${username}
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue