config-perso/kat/ssh-keys/default.nix

24 lines
489 B
Nix

{ lib }:
let
inherit (lib)
filterAttrs
trim
splitString
filter
hasPrefix
readFile
mapAttrs'
removeSuffix
;
key-files = filterAttrs (name: _: name != "default.nix") (builtins.readDir ./.);
readKeys =
file:
let
lines = map trim (splitString "\n" (readFile file));
in
filter (line: line != "" && !hasPrefix "#" line) lines;
in
mapAttrs' (name: _: {
name = removeSuffix ".keys" name;
value = readKeys ./${name};
}) key-files