2024-12-12 10:39:49 +01:00
|
|
|
let
|
|
|
|
inherit (builtins)
|
2024-12-13 12:19:26 +01:00
|
|
|
attrValues
|
2024-12-12 10:39:49 +01:00
|
|
|
elemAt
|
2024-12-13 12:19:26 +01:00
|
|
|
foldl'
|
2024-12-12 10:39:49 +01:00
|
|
|
mapAttrs
|
|
|
|
match
|
|
|
|
readDir
|
|
|
|
readFile
|
|
|
|
;
|
2024-12-13 12:19:26 +01:00
|
|
|
## `mergeAttrs` and `concatMapAttrs` are in `lib.trivial` and `lib.attrsets`,
|
|
|
|
## but we would rather avoid a dependency in nixpkgs for this file.
|
|
|
|
mergeAttrs = x: y: x // y;
|
|
|
|
concatMapAttrs = f: v: foldl' mergeAttrs { } (attrValues (mapAttrs f v));
|
|
|
|
removePubSuffix =
|
|
|
|
s:
|
|
|
|
let
|
|
|
|
maybeMatch = match "(.*)\.pub" s;
|
|
|
|
in
|
|
|
|
if maybeMatch == null then s else elemAt maybeMatch 0;
|
2024-12-12 10:39:49 +01:00
|
|
|
removeTrailingWhitespace = s: elemAt (match "(.*[^[:space:]])[[:space:]]*" s) 0;
|
2024-12-13 12:19:26 +01:00
|
|
|
|
2024-12-12 10:39:49 +01:00
|
|
|
collectKeys =
|
2024-12-13 12:19:26 +01:00
|
|
|
dir:
|
|
|
|
concatMapAttrs (name: _: {
|
|
|
|
"${removePubSuffix name}" = removeTrailingWhitespace (readFile (dir + "/${name}"));
|
|
|
|
}) (readDir dir);
|
2024-12-12 10:39:49 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
contributors = collectKeys ./contributors;
|
|
|
|
systems = collectKeys ./systems;
|
|
|
|
}
|