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

View file

@ -25,6 +25,7 @@
ghostty.enable = true; ghostty.enable = true;
foot.enable = false; foot.enable = false;
starship.enable = true; starship.enable = true;
sops.enable = true;
}; };
xdg.userDirs = { xdg.userDirs = {
@ -61,13 +62,11 @@
gawk gawk
zstd zstd
tree tree
nerd-fonts.victor-mono
ouch ouch
dust dust
qq qq
telegram-desktop telegram-desktop
ghostty ghostty
sops
scrcpy scrcpy
ast-grep ast-grep
lazygit lazygit
@ -123,10 +122,4 @@
format = "yaml"; format = "yaml";
sopsFile = rootPath + "/secrets/ssh-config.yaml"; sopsFile = rootPath + "/secrets/ssh-config.yaml";
}; };
sops.age = {
keyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt";
generateKey = false;
};
sops.defaultSopsFile = rootPath + "/secrets/general.yaml";
} }

View file

@ -13,6 +13,7 @@
./ghostty.nix ./ghostty.nix
./foot ./foot
./starship ./starship
./sops.nix
]; ];
options = { options = {

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";
};
};
}