refactor(modules): clean up folder structure

This commit is contained in:
Mohammad Rafiq 2025-07-07 19:24:36 +08:00
parent d8aa7f62b4
commit 03fca8b28b
No known key found for this signature in database
12 changed files with 32 additions and 38 deletions

View 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}
'';
}
];
};
}