mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
26 lines
724 B
Nix
26 lines
724 B
Nix
with builtins;
|
|
let
|
|
extractName = string:
|
|
let
|
|
metadata = [
|
|
"pub" "public" "priv" "private"
|
|
"key" "file" "." "_" "-" "pk"
|
|
];
|
|
in
|
|
replaceStrings metadata (builtins.map (_: "") metadata) string;
|
|
|
|
constructKeys = dir: (
|
|
listToAttrs (
|
|
map (subdir: {
|
|
name = subdir;
|
|
value = listToAttrs (
|
|
map (file: {
|
|
name = extractName file;
|
|
value = readFile "${dir}/${subdir}/${file}";
|
|
}) (filter (node: (readDir "${dir}/${subdir}").${node} == "regular") (attrNames (readDir "${dir}/${subdir}")))
|
|
);
|
|
}) (filter (node: (readDir dir).${node} == "directory") (attrNames (readDir dir)))
|
|
)
|
|
);
|
|
in
|
|
constructKeys ./.
|