changes to sops and cleanup script works globally

This commit is contained in:
cnst
2024-08-18 16:24:40 +02:00
parent 9490d52c53
commit 35f731b673
11 changed files with 155 additions and 115 deletions

View File

@@ -5,60 +5,34 @@
config,
...
}: let
defaultConfig = {
age = {sshKeyPaths = ["/home/cnst/.ssh/id_ed25519"];};
defaultSopsFile = "${self}/secrets/cnst-secrets.yaml";
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/cnst-secrets.yaml";
};
ssh_user = {
format = "yaml";
sopsFile = "${self}/secrets/cnst-secrets.yaml";
};
};
};
userSpecificConfig = lib.mkMerge [
(lib.mkIf (config.home.username == "toothpick") {
age = {sshKeyPaths = ["/home/toothpick/.ssh/id_ed25519"];};
defaultSopsFile = "${self}/secrets/toothpick-secrets.yaml";
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/toothpick-secrets.yaml";
};
ssh_user = {
format = "yaml";
sopsFile = "${self}/secrets/toothpick-secrets.yaml";
};
};
})
(lib.mkIf (config.home.username == "adam") {
age = {sshKeyPaths = ["/home/adam/.ssh/id_ed25519"];};
defaultSopsFile = "${self}/secrets/adam-secrets.yaml";
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/adam-secrets.yaml";
};
ssh_user = {
format = "yaml";
sopsFile = "${self}/secrets/adam-secrets.yaml";
};
};
})
];
inherit (lib) mkIf mkEnableOption;
inherit (lib) mkIf mkEnableOption mkOption;
cfg = config.modules.userd.sops;
in {
imports = [
inputs.sops-nix.homeManagerModules.sops
];
options = {
modules.userd.sops.enable = mkEnableOption "Enables sops home environment";
modules.userd.sops = {
enable = mkEnableOption "Enables sops home environment";
cnst = mkOption {
type = lib.types.bool;
default = false;
description = "Apply cnst sops settings";
};
toothpick = mkOption {
type = lib.types.bool;
default = false;
description = "Apply toothpick sops settings";
};
adam = mkOption {
type = lib.types.bool;
default = false;
description = "Apply adam sops settings";
};
};
};
config = mkIf cfg.enable {
sops = lib.mkMerge [
{
@@ -67,8 +41,45 @@ in {
sshKeyPaths = [];
};
}
defaultConfig
userSpecificConfig
(mkIf cfg.cnst {
age = {sshKeyPaths = ["/home/cnst/.ssh/id_ed25519"];};
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/cnst-secrets.yaml";
};
ssh_user = {
format = "yaml";
sopsFile = "${self}/secrets/cnst-secrets.yaml";
};
};
})
(mkIf cfg.toothpick {
age = {sshKeyPaths = ["/home/toothpick/.ssh/id_ed25519"];};
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/toothpick-secrets.yaml";
};
ssh_user = {
format = "yaml";
sopsFile = "${self}/secrets/toothpick-secrets.yaml";
};
};
})
(mkIf cfg.adam {
age = {sshKeyPaths = ["/home/adam/.ssh/id_ed25519"];};
secrets = {
openai_api_key = {
format = "yaml";
sopsFile = "${self}/secrets/adam-secrets.yaml";
};
ssh_user = {
format = "yaml";
sopsFile = "${self}/secrets/adam-secrets.yaml";
};
};
})
];
};
}

View File

@@ -22,7 +22,10 @@
zellij.enable = false;
};
userd = {
sops.enable = false;
sops = {
enable = false;
adam = false;
};
copyq.enable = true;
mako.enable = true;
udiskie.enable = true;

View File

@@ -11,14 +11,14 @@
umod = "nvim /home/adam/.nix-config/home/users/adam/modules.nix";
systemmodules = "nvim /home/adam/.nix-config/hosts/adampad/modules.nix";
smod = "nvim /home/adam/.nix-config/hosts/adampad/modules.nix";
nixclean = "sudo nix run .#cleanup-boot";
nixclean = "sudo nix run /home/adam/.nix-config#cleanup-boot";
nixdev = "nix develop ~/.nix-config -c $SHELL";
nixconfig = "cd /home/adam/.nix-config/";
ll = "ls -l";
nixupdate = "nh os switch -v -H adampad && sudo nix run .#cleanup-boot";
nixup = "nh os switch -H adampad && sudo nix run .#cleanup-boot";
flakeupdate = "nh os switch -u -v -H adampad && sudo nix run .#cleanup-boot";
flakeup = "nh os switch -u -H adampad && sudo nix run .#cleanup-boot";
nixupdate = "nh os switch -v -H adampad && sudo nix run /home/adam/.nix-config#cleanup-boot";
nixup = "nh os switch -H adampad && sudo nix run /home/adam/.nix-config#cleanup-boot";
flakeupdate = "nh os switch -u -v -H adampad && sudo nix run /home/adam/.nix-config#cleanup-boot";
flakeup = "nh os switch -u -H adampad && sudo nix run /home/adam/.nix-config#cleanup-boot";
};
history = {
size = 1000;

View File

@@ -22,7 +22,10 @@
zellij.enable = false;
};
userd = {
sops.enable = true;
sops = {
enable = true;
cnst = true;
};
copyq.enable = true;
mako.enable = true;
udiskie.enable = true;

View File

@@ -11,14 +11,14 @@
umod = "nvim /home/cnst/.nix-config/home/users/cnst/modules.nix";
systemmodules = "nvim /home/cnst/.nix-config/hosts/cnix/modules.nix";
smod = "nvim /home/cnst/.nix-config/hosts/cnix/modules.nix";
nixclean = "sudo nix run .#cleanup-boot";
nixclean = "sudo nix run /home/cnst/.nix-config#cleanup-boot";
nixdev = "nix develop ~/.nix-config -c $SHELL";
nixconfig = "cd /home/cnst/.nix-config/";
ll = "ls -l";
nixupdate = "nh os switch -v -H cnix && sudo nix run .#cleanup-boot";
nixup = "nh os switch -H cnix && sudo nix run .#cleanup-boot";
flakeupdate = "nh os switch -u -v -H cnix && sudo nix run .#cleanup-boot";
flakeup = "nh os switch -u -H cnix && sudo nix run .#cleanup-boot";
nixupdate = "nh os switch -v -H cnix && sudo nix run /home/cnst/.nix-config#cleanup-boot";
nixup = "nh os switch -H cnix && sudo nix run /home/cnst/.nix-config#cleanup-boot";
flakeupdate = "nh os switch -u -v -H cnix && sudo nix run /home/cnst/.nix-config#cleanup-boot";
flakeup = "nh os switch -u -H cnix && sudo nix run /home/cnst/.nix-config#cleanup-boot";
};
history = {
size = 1000;

View File

@@ -22,7 +22,10 @@
zellij.enable = false;
};
userd = {
sops.enable = false;
sops = {
enable = false;
toothpick = false;
};
copyq.enable = true;
mako.enable = true;
udiskie.enable = true;

View File

@@ -11,14 +11,14 @@
umod = "nvim /home/toothpick/.nix-config/home/users/toothpick/modules.nix";
systemmodules = "nvim /home/toothpick/.nix-config/hosts/toothpc/modules.nix";
smod = "nvim /home/toothpick/.nix-config/hosts/toothpc/modules.nix";
nixclean = "sudo nix run .#cleanup-boot";
nixclean = "sudo nix run /home/toothpick/.nix-config#cleanup-boot";
nixdev = "nix develop ~/.nix-config -c $SHELL";
nixconfig = "cd /home/toothpick/.nix-config/";
ll = "ls -l";
nixupdate = "nh os switch -v -H toothpc && sudo nix run .#cleanup-boot";
nixup = "nh os switch -H toothpc && sudo nix run .#cleanup-boot";
flakeupdate = "nh os switch -u -v -H toothpc && sudo nix run .#cleanup-boot";
flakeup = "nh os switch -u -H toothpc && sudo nix run .#cleanup-boot";
nixupdate = "nh os switch -v -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
nixup = "nh os switch -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
flakeupdate = "nh os switch -u -v -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
flakeup = "nh os switch -u -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
};
history = {
size = 1000;