nixos/btrbk: Optimize sort

This avoids computing the prio more than necessary.
The test evaluates to the same derivation hash.
This commit is contained in:
Robert Hensing 2023-12-07 20:02:13 +01:00
parent 016993237f
commit 7438f4e0de

View file

@ -13,7 +13,7 @@ let
mkIf
mkOption
optionalString
sort
sortOn
types
;
@ -37,7 +37,7 @@ let
genConfig = set:
let
pairs = mapAttrsToList (name: value: { inherit name value; }) set;
sortedPairs = sort (a: b: prioOf a < prioOf b) pairs;
sortedPairs = sortOn prioOf pairs;
in
concatMap genPair sortedPairs;
genSection = sec: secName: value: