From 96144fde81e63b2c05dce2ced8f30cdac585ea2f Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Mon, 27 Jun 2022 20:45:10 +0200 Subject: [PATCH] update-flake.nix: fix stable pkgs selection In rare cases, the nixpkgs stable version of a package can be newer than in unstable nixpkgs. [1] When this happens, choose the newer stable version instead of the older unstable version. [1] E.g., when a package is updated in both nixpkgs stable and unstable, and nixpkgs stable is released before unstable. --- helper/update-flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helper/update-flake.nix b/helper/update-flake.nix index 43fbd9c..2bc592e 100644 --- a/helper/update-flake.nix +++ b/helper/update-flake.nix @@ -8,8 +8,8 @@ in rec { # stable = { bitcoind = "0.21.1"; ... }; # unstable = { btcpayserver = "1.2.1"; ... }; # } - # A pinned pkg is added to `stable` if the stable and unstable pkg versions - # are identical. + # A pinned pkg is added to `stable` if its stable version is newer or + # identical to the unstable version. versions = let pinned = flake.legacyPackages.x86_64-linux.pinned; pinnedPkgs = lib.filterAttrs (n: v: lib.isDerivation v) pinned; @@ -17,7 +17,8 @@ in rec { unstable = pinned.pkgsUnstable; isStable = builtins.partition (pkgName: !(unstable ? "${pkgName}") || - ((stable ? "${pkgName}") && stable.${pkgName}.version == unstable.${pkgName}.version) + ((stable ? "${pkgName}") + && (builtins.compareVersions stable.${pkgName}.version unstable.${pkgName}.version >= 0)) ) (builtins.attrNames pinnedPkgs); in { stable = lib.genAttrs isStable.right (pkgName: stable.${pkgName}.version);