sync sops and users

Signed-off-by: unexplrd <unexplrd@linerds.us>
This commit is contained in:
2025-04-06 13:38:15 +03:00
parent d5521a468d
commit 1f0bbc9daf
4 changed files with 60 additions and 70 deletions

View File

@ -3,9 +3,15 @@
inputs,
...
}: let
s = inputs.mysecrets;
hostname = config.networking.hostName;
sopsFile = "${s}/hosts/${hostname}.yaml";
inherit (inputs) mysecrets;
# TODO: stop relying on networking.hostName
inherit (config.networking) hostName;
sopsFile = mysecrets + "/hosts/${hostName}.yaml";
dotSsh = name: "/home/user/.ssh/" + name;
sshKey = {
mode = "0400";
owner = "user";
};
in {
imports = with inputs; [
sops-nix.nixosModules.sops
@ -17,45 +23,39 @@ in {
keyFile = "/var/lib/sops-nix/key.txt";
generateKey = true;
};
defaultSopsFile = "${s}/common.yaml";
defaultSopsFile = mysecrets + "/common.yaml";
secrets = {
"user-password-hashed".neededForUsers = true;
"ssh-config" = {
path = "/home/user/.ssh/config";
path = dotSsh "config";
mode = "0400";
owner = "user";
};
"ssh-${hostname}-user" = {
"ssh-${hostName}-user" = {
inherit sopsFile;
path = "/home/user/.ssh/id_ed25519";
mode = "0400";
owner = "user";
inherit (sshKey) mode owner;
path = dotSsh "id_ed25519";
};
"ssh-${hostname}-user.pub" = {
"ssh-${hostName}-user.pub" = {
inherit sopsFile;
path = "/home/user/.ssh/id_ed25519.pub";
mode = "0400";
owner = "user";
inherit (sshKey) mode owner;
path = dotSsh "id_ed25519.pub";
};
"ssh-unexplrd" = {
path = "/home/user/.ssh/id_unexplrd_ed25519";
mode = "0400";
owner = "user";
inherit (sshKey) mode owner;
path = dotSsh "id_unexplrd_ed25519";
};
"ssh-unexplrd.pub" = {
path = "/home/user/.ssh/id_unexplrd_ed25519.pub";
mode = "0400";
owner = "user";
inherit (sshKey) mode owner;
path = dotSsh "id_unexplrd_ed25519.pub";
};
"ssh-uni" = {
path = "/home/user/.ssh/id_uni_ed25519";
mode = "0400";
owner = "user";
inherit (sshKey) mode owner;
path = dotSsh "id_uni_ed25519";
};
"ssh-uni.pub" = {
path = "/home/user/.ssh/id_uni_ed25519.pub";
mode = "0400";
owner = "user";
inherit (sshKey) mode owner;
path = dotSsh "id_uni_ed25519.pub";
};
};
};