From ef6ac2dd6e6fe0f800d008fd9e314226617fb96a Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 26 Dec 2024 23:00:05 +0000 Subject: [PATCH] coqPackages.metaFetch: fix `sort` predicate stability Incorrect sorting predicate was found as part of https://github.com/NixOS/nix/issues/12106 where `nix` was crashing on the code like: $ nix eval --expr 'builtins.sort (a: b: true) [ 1 2 3 ]' ... Aborted (core dumped) Note: the crash happens here because sorting predicate does not implement `lessThan` and triggers assertion failures for `std::stable_sort` that backs `builtins.sort`. The change restores `lessThan` semantic for `version sorting`. --- pkgs/build-support/coq/meta-fetch/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/coq/meta-fetch/default.nix b/pkgs/build-support/coq/meta-fetch/default.nix index 7491d0205c251..cc435b299cfd6 100644 --- a/pkgs/build-support/coq/meta-fetch/default.nix +++ b/pkgs/build-support/coq/meta-fetch/default.nix @@ -27,7 +27,7 @@ let sort switch switch-if - versionAtLeast + versionOlder versions ; @@ -112,7 +112,7 @@ let shortVersion = x: if (isString x && match "^/.*" x == null) then - findFirst (v: versions.majorMinor v == x) null (sort versionAtLeast (attrNames release)) + findFirst (v: versions.majorMinor v == x) null (sort (l: r: versionOlder r l) (attrNames release)) else null; isShortVersion = x: shortVersion x != null;