From bf740322a7699bf579af3527e748edf2d49190ed Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 26 Dec 2024 23:09:02 +0000 Subject: [PATCH] mathematica: 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/applications/science/math/mathematica/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/science/math/mathematica/default.nix b/pkgs/applications/science/math/mathematica/default.nix index b3dba1b7c6de..29e7aa77cc02 100644 --- a/pkgs/applications/science/math/mathematica/default.nix +++ b/pkgs/applications/science/math/mathematica/default.nix @@ -30,7 +30,7 @@ let versions = callPackage ./versions.nix { }; - matching-versions = lib.sort (v1: v2: lib.versionAtLeast v1.version v2.version) ( + matching-versions = lib.sort (v1: v2: lib.versionOlder v2.version v1.version) ( lib.filter ( v: v.lang == lang && (version == null || isMatching v.version version) && matchesDoc v ) versions