move home sops config to module

This commit is contained in:
ulic-youthlic 2025-01-12 20:19:42 +08:00
parent 991a8b4bbc
commit 4087865b8f
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
3 changed files with 50 additions and 8 deletions

48
home/modules/sops.nix Normal file
View file

@ -0,0 +1,48 @@
{
lib,
config,
pkgs,
rootPath,
...
}:
{
options = {
youthlic.programs.sops = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = ''
whether enable sops-nix or not
'';
};
keyFile = lib.mkOption {
type = lib.types.nonEmptyStr;
default = "${config.home.homeDirectory}/.config/sops/age/keys.txt";
description = ''
path to age key file
'';
};
};
};
config =
let
cfg = config.youthlic.programs.sops;
in
lib.mkIf cfg.enable {
home.packages = (
with pkgs;
[
sops
age
]
);
sops = {
age = {
keyFile = cfg.keyFile;
generateKey = false;
};
defaultSopsFile = rootPath + "/secrets/general.yaml";
};
};
}