From 7438f4e0de4f41a562c4292a035f406129208bfd Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 7 Dec 2023 20:02:13 +0100 Subject: [PATCH] nixos/btrbk: Optimize sort This avoids computing the prio more than necessary. The test evaluates to the same derivation hash. --- nixos/modules/services/backup/btrbk.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/backup/btrbk.nix b/nixos/modules/services/backup/btrbk.nix index 1e90ef54d33f..3cbbf0f1bd5c 100644 --- a/nixos/modules/services/backup/btrbk.nix +++ b/nixos/modules/services/backup/btrbk.nix @@ -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: