Refactor ssh-keys location.
This commit is contained in:
parent
01353b87ac
commit
407928712c
5 changed files with 10 additions and 28 deletions
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: {
|
||||
utils = import ./utils.nix;
|
||||
getSSHKeys = (import ./keys.nix).getSSHKeys;
|
||||
getSSHKeys = (import ./data.nix).getSSHKeys;
|
||||
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