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.
This commit is contained in:
parent
1ba7ccc547
commit
96144fde81
@ -8,8 +8,8 @@ in rec {
|
|||||||
# stable = { bitcoind = "0.21.1"; ... };
|
# stable = { bitcoind = "0.21.1"; ... };
|
||||||
# unstable = { btcpayserver = "1.2.1"; ... };
|
# unstable = { btcpayserver = "1.2.1"; ... };
|
||||||
# }
|
# }
|
||||||
# A pinned pkg is added to `stable` if the stable and unstable pkg versions
|
# A pinned pkg is added to `stable` if its stable version is newer or
|
||||||
# are identical.
|
# identical to the unstable version.
|
||||||
versions = let
|
versions = let
|
||||||
pinned = flake.legacyPackages.x86_64-linux.pinned;
|
pinned = flake.legacyPackages.x86_64-linux.pinned;
|
||||||
pinnedPkgs = lib.filterAttrs (n: v: lib.isDerivation v) pinned;
|
pinnedPkgs = lib.filterAttrs (n: v: lib.isDerivation v) pinned;
|
||||||
@ -17,7 +17,8 @@ in rec {
|
|||||||
unstable = pinned.pkgsUnstable;
|
unstable = pinned.pkgsUnstable;
|
||||||
isStable = builtins.partition (pkgName:
|
isStable = builtins.partition (pkgName:
|
||||||
!(unstable ? "${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);
|
) (builtins.attrNames pinnedPkgs);
|
||||||
in {
|
in {
|
||||||
stable = lib.genAttrs isStable.right (pkgName: stable.${pkgName}.version);
|
stable = lib.genAttrs isStable.right (pkgName: stable.${pkgName}.version);
|
||||||
|
Loading…
Reference in New Issue
Block a user