Add machines.keys config and reorganize key structure

- Add config.machines.keys for machine-specific keys (private keys live on that machine)
- Move desktop SSH key to machines.keys.desktop.ssh
- Fix extractName to preserve "yubikey" (only strip .key/.pub extensions)
- Rename key files for clarity (android -> graphone, primary -> yubikey)
- Add age yubikey key for encrypted backups
- Add README files to document key purposes
- Update all machine configs to import system config
This commit is contained in:
Bryan Ramos 2026-03-12 15:17:46 -04:00
parent 570a321e53
commit 960904cbd9
24 changed files with 94 additions and 20 deletions

View file

@ -0,0 +1,14 @@
{ lib, pkgs, config, ... }:
with lib;
{
options = {
machines = mkOption {
description = "Machine Configurations";
type = types.attrs;
default = {
keys = import ./keys { inherit lib; };
};
};
};
}

View file

@ -0,0 +1,33 @@
{ lib }:
with builtins;
let
extractName = filename:
let
# Remove .key extension
noKey = lib.removeSuffix ".key" filename;
# Remove .pub/.priv/.public/.private markers
noMarkers = replaceStrings
[ ".pub" ".priv" ".public" ".private" ]
[ "" "" "" "" ]
noKey;
in noMarkers;
constructKeys = dir: (
listToAttrs (
map (subdir: {
name = subdir;
value = listToAttrs (
map (file: {
name = extractName file;
value = readFile "${dir}/${subdir}/${file}";
}) (filter (file:
(readDir "${dir}/${subdir}").${file} == "regular" &&
lib.hasSuffix ".key" file
) (attrNames (readDir "${dir}/${subdir}")))
);
}) (filter (node: (readDir dir).${node} == "directory") (attrNames (readDir dir)))
)
);
in
constructKeys ./.

View file

@ -0,0 +1,3 @@
# Desktop Keys
ssh.pub.key - ~/.ssh/id_rsa

View file

@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOYXfu4Jc/HtdyhOfAdCXYzhqCubIq3Bz6Kl9NDUov76 bryan@desktop

View file

@ -3,6 +3,7 @@
{
imports = [
../../../user/config
../../config
./hardware.nix
./system.nix
./modules/disko

View file

@ -13,7 +13,7 @@ in
isNormalUser = true;
extraGroups = config.user.groups
++ [ "video" "audio" "kvm" "libvirtd" "dialout" ];
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.android}" ];
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.graphone}" ];
};
};

View file

@ -3,6 +3,7 @@
{
imports = [
../../../user/config
../../config
./hardware.nix
./system.nix
];

View file

@ -12,13 +12,12 @@
backup = {
enable = true;
recipients = [
# TODO: Add your age recipients
# "${config.user.keys.age.yubikey}"
# "${config.user.keys.ssh.desktop}"
"${config.user.keys.age.yubikey}"
"${config.machines.keys.desktop.ssh}"
];
destination = "gdrive:backups/server"; # TODO: configure rclone remote
schedule = "daily";
keepLast = 7;
keepLast = 2;
};
};
@ -27,7 +26,7 @@
isNormalUser = true;
extraGroups = config.user.groups;
openssh.authorizedKeys.keys = [
"${config.user.keys.ssh.desktop}"
"${config.machines.keys.desktop.ssh}"
];
};
};

View file

@ -3,6 +3,7 @@
{
imports = [
../../../user/config
../../config
./hardware.nix
./system.nix
];

View file

@ -8,7 +8,7 @@
${config.user.name} = {
isNormalUser = true;
extraGroups = config.user.groups;
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.primary}" ];
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.yubikey}" ];
};
};

View file

@ -3,6 +3,7 @@
{
imports = [
../../../user/config
../../config
./hardware.nix
./system.nix
];

View file

@ -10,7 +10,7 @@ with lib;
extraGroups = config.user.groups
++ [ "video" "audio" "kvm" "libvirtd" "dialout" ];
openssh.authorizedKeys.keys = [
"${config.user.keys.ssh.primary}"
"${config.user.keys.ssh.yubikey}"
"${config.user.keys.ssh.work}"
];
};

View file

@ -3,6 +3,7 @@
{
imports = [
../../../user/config
../../config
./system.nix
];
}

View file

@ -9,8 +9,7 @@
isNormalUser = true;
extraGroups = config.user.groups;
openssh.authorizedKeys.keys = [
"${config.user.keys.ssh.primary}"
"${config.user.keys.ssh.windows}"
"${config.user.keys.ssh.yubikey}"
];
};
};