2 lib = import ../../lib;
4 add attrNames elemAt foldl' genList length replaceStrings sort toLower trace;
6 maintainers = import ../maintainer-list.nix;
7 simplify = replaceStrings [ "-" "_" ] [ "" "" ];
8 compare = a: b: simplify (toLower a) < simplify (toLower b);
13 (n: let pos = builtins.unsafeGetAttrPos n maintainers;
14 in assert pos == null -> throw "maintainers entry ${n} is malformed";
15 { name = n; line = pos.line; key = toLower (simplify n); })
16 (attrNames maintainers));
17 before = { name, line, key }:
19 (acc: n: if n.key < key && (acc == null || n.key > acc.key) then n else acc)
24 (i: let a = elemAt namesSorted i;
25 b = elemAt namesSorted (i + 1);
26 lim = let t = before a; in if t == null then "the initial {" else t.name;
27 in if a.line >= b.line
29 ("maintainer ${a.name} (line ${toString a.line}) should be listed "
30 + "after ${lim}, not after ${b.name} (line ${toString b.line})")
33 (genList (i: i) (length namesSorted - 1)));
35 assert errors == 0; "all good!"
37 # generate edit commands to sort the list.
38 # may everything following the last current entry (closing } ff) in the wrong place
42 # (let first = foldl' (acc: n: if n.line < acc then n.line else acc) 999999999 namesSorted;
44 # (i: let e = elemAt namesSorted i;
46 # (acc: n: if n.line < e.line && n.line > acc then n.line else acc)
50 # foldl' (acc: n: if n.line > e.line && n.line < acc then n.line else acc)
53 # in "${toString e.line},${toString (end - 1)} p")
54 # (genList (i: i) (length namesSorted));
56 # (c: "sed -ne '${c}' maintainers/maintainer-list.nix")
57 # ([ "1,${toString (first - 1)} p" ] ++ commands))