Refactor ssh-keys location.
This commit is contained in:
parent
01353b87ac
commit
407928712c
5 changed files with 10 additions and 28 deletions
3
data/ssh-keys.toml
Normal file
3
data/ssh-keys.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[foehammer]
|
||||||
|
leni = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDTIngMpTALLFEU4bDnPWCy7mznZZiPWw9vuYEAJ5zA0 foehammer@lorenzo-leni"
|
||||||
|
yubikey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtCcKS1jN/WSb4Ggvpz11pkUdE4kMgrN0xwptXLgSBX openpgp:0x79EFAC41"
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
leni = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDTIngMpTALLFEU4bDnPWCy7mznZZiPWw9vuYEAJ5zA0 foehammer@lorenzo-leni";
|
|
||||||
|
|
||||||
yubikey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtCcKS1jN/WSb4Ggvpz11pkUdE4kMgrN0xwptXLgSBX openpgp:0x79EFAC41";
|
|
||||||
}
|
|
||||||
6
lib/data.nix
Normal file
6
lib/data.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
rec {
|
||||||
|
getSSHKeys = let
|
||||||
|
sshKeys = builtins.fromTOML (builtins.readFile ../data/ssh-keys.toml);
|
||||||
|
in
|
||||||
|
name: (builtins.mapAttrs (_: value: builtins.attrValues value) sshKeys)."${name}";
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
nixpkgs: withSystem: {
|
nixpkgs: withSystem: {
|
||||||
utils = import ./utils.nix;
|
utils = import ./utils.nix;
|
||||||
getSSHKeys = (import ./keys.nix).getSSHKeys;
|
getSSHKeys = (import ./data.nix).getSSHKeys;
|
||||||
mkSystem = (import ./nixos.nix nixpkgs withSystem).mkSystem;
|
mkSystem = (import ./nixos.nix nixpkgs withSystem).mkSystem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
lib/keys.nix
22
lib/keys.nix
|
|
@ -1,22 +0,0 @@
|
||||||
let
|
|
||||||
utils = import ./utils.nix;
|
|
||||||
in rec {
|
|
||||||
getSSHKeys = name: (getKeySets ../keys)."${name}";
|
|
||||||
|
|
||||||
getKeySets = dir: let
|
|
||||||
entries = builtins.readDir dir;
|
|
||||||
|
|
||||||
procEntry = name: type: let
|
|
||||||
path = dir + "/${name}";
|
|
||||||
in
|
|
||||||
if type == "regular"
|
|
||||||
then [
|
|
||||||
{
|
|
||||||
name = utils.getName name;
|
|
||||||
value = builtins.attrValues (import path);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else [];
|
|
||||||
in
|
|
||||||
builtins.listToAttrs (builtins.concatLists (builtins.attrValues (builtins.mapAttrs procEntry entries)));
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue