Initial Commit
This commit is contained in:
commit
d07ba813bf
14 changed files with 360 additions and 0 deletions
28
nixos/lib/keys.nix
Normal file
28
nixos/lib/keys.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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 = getName name;
|
||||
value = builtins.attrValues (import path);
|
||||
}
|
||||
]
|
||||
else [];
|
||||
in
|
||||
builtins.listToAttrs (builtins.concatLists (builtins.attrValues (builtins.mapAttrs procEntry entries)));
|
||||
|
||||
getName = filename: let
|
||||
parts = builtins.split "\\." filename;
|
||||
base = builtins.head (builtins.split "\\." filename);
|
||||
in
|
||||
if builtins.length parts == 1
|
||||
then filename
|
||||
else base;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue