Skip to content

Commit 0e59e7b

Browse files
committed
nix: simplify version checks
1 parent 9e46b6e commit 0e59e7b

File tree

1 file changed

+24
-35
lines changed

1 file changed

+24
-35
lines changed

pkgs/tools/package-management/nix/common.nix

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010
}@args:
1111
assert (hash == null) -> (src != null);
1212
let
13-
atLeast24 = lib.versionAtLeast version "2.4pre";
14-
atLeast25 = lib.versionAtLeast version "2.5pre";
15-
atLeast27 = lib.versionAtLeast version "2.7pre";
16-
atLeast210 = lib.versionAtLeast version "2.10pre";
17-
atLeast213 = lib.versionAtLeast version "2.13pre";
18-
atLeast214 = lib.versionAtLeast version "2.14pre";
19-
atLeast218 = lib.versionAtLeast version "2.18pre";
20-
atLeast219 = lib.versionAtLeast version "2.19pre";
21-
atLeast220 = lib.versionAtLeast version "2.20pre";
22-
atLeast221 = lib.versionAtLeast version "2.21pre";
2313
atLeast224 = lib.versionAtLeast version "2.24pre";
2414
atLeast225 = lib.versionAtLeast version "2.25pre";
2515
# Major.minor versions unaffected by CVE-2024-27297
@@ -112,7 +102,7 @@ self = stdenv.mkDerivation {
112102
"shadowstack"
113103
] ++ lib.optional stdenv.hostPlatform.isMusl "fortify";
114104

115-
nativeInstallCheckInputs = lib.optional atLeast221 git ++ lib.optional atLeast219 man;
105+
nativeInstallCheckInputs = lib.optional atLeast224 [ git man ];
116106

117107
nativeBuildInputs = [
118108
pkg-config
@@ -121,17 +111,18 @@ self = stdenv.mkDerivation {
121111
bison
122112
flex
123113
jq
124-
] ++ lib.optionals (enableDocumentation && !atLeast24) [
125-
libxslt
126-
libxml2
127-
docbook_xsl_ns
128-
docbook5
129-
] ++ lib.optionals (enableDocumentation && atLeast24) [
130-
(lib.getBin lowdown-unsandboxed)
131-
mdbook
132-
] ++ lib.optionals (atLeast213 && enableDocumentation) [
133-
mdbook-linkcheck
134-
] ++ lib.optionals stdenv.hostPlatform.isLinux [
114+
] ++ lib.optionals enableDocumentation
115+
(if atLeast224 then [
116+
(lib.getBin lowdown-unsandboxed)
117+
mdbook
118+
mdbook-linkcheck
119+
] else [
120+
libxslt
121+
libxml2
122+
docbook_xsl_ns
123+
docbook5
124+
])
125+
++ lib.optionals stdenv.hostPlatform.isLinux [
135126
util-linuxMinimal
136127
];
137128

@@ -148,23 +139,21 @@ self = stdenv.mkDerivation {
148139
gtest
149140
libarchive
150141
lowdown
151-
] ++ lib.optionals atLeast220 [
142+
] ++ lib.optionals atLeast224 [
152143
libgit2
153-
] ++ lib.optionals (atLeast224 || lib.versionAtLeast version "pre20240626") [
154144
toml11
145+
rapidcheck
155146
] ++ lib.optionals (atLeast225 && enableDocumentation) [
156147
python3
157148
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
158149
Security
159150
] ++ lib.optionals (stdenv.hostPlatform.isx86_64) [
160151
libcpuid
161-
] ++ lib.optionals atLeast214 [
162-
rapidcheck
163152
] ++ lib.optionals withLibseccomp [
164153
libseccomp
165154
] ++ lib.optionals withAWS [
166155
aws-sdk-cpp
167-
] ++ lib.optional (atLeast218 && stdenv.hostPlatform.isDarwin) [
156+
] ++ lib.optional (atLeast224 && stdenv.hostPlatform.isDarwin) [
168157
darwin.apple_sdk.libs.sandbox
169158
] ++ lib.optional (atLeast224 && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
170159
# Fix the following error with the default x86_64-darwin SDK:
@@ -179,7 +168,7 @@ self = stdenv.mkDerivation {
179168

180169
propagatedBuildInputs = [
181170
boehmgc
182-
] ++ lib.optionals atLeast27 [
171+
] ++ lib.optionals atLeast224 [
183172
nlohmann_json
184173
];
185174

@@ -203,7 +192,7 @@ self = stdenv.mkDerivation {
203192
# removes config.nix entirely and is not present in 2.3.x, we need to
204193
# patch around an issue where the Nix configure step pulls in the build
205194
# system's bash and other utilities when cross-compiling.
206-
lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform && !atLeast24) ''
195+
lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform && !atLeast224) ''
207196
mkdir tmp/
208197
substitute corepkgs/config.nix.in tmp/config.nix.in \
209198
--subst-var-by bash ${bash}/bin/bash \
@@ -225,14 +214,14 @@ self = stdenv.mkDerivation {
225214
"--disable-doc-gen"
226215
] ++ lib.optionals stdenv.hostPlatform.isLinux [
227216
"--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox"
228-
] ++ lib.optionals (atLeast210 && stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isStatic) [
217+
] ++ lib.optionals (atLeast224 && stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isStatic) [
229218
"--enable-embedded-sandbox-shell"
230219
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform ? nix && stdenv.hostPlatform.nix ? system) [
231220
"--with-system=${stdenv.hostPlatform.nix.system}"
232221
] ++ lib.optionals (!withLibseccomp) [
233222
# RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
234223
"--disable-seccomp-sandboxing"
235-
] ++ lib.optionals (atLeast210 && stdenv.cc.isGNU && !enableStatic) [
224+
] ++ lib.optionals (atLeast224 && stdenv.cc.isGNU && !enableStatic) [
236225
"--enable-lto"
237226
];
238227

@@ -248,7 +237,7 @@ self = stdenv.mkDerivation {
248237
installFlags = [ "sysconfdir=$(out)/etc" ];
249238

250239
doInstallCheck = true;
251-
installCheckTarget = if atLeast210 then "installcheck" else null;
240+
installCheckTarget = if atLeast224 then "installcheck" else null;
252241

253242
# socket path becomes too long otherwise
254243
preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
@@ -260,17 +249,17 @@ self = stdenv.mkDerivation {
260249
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
261250
''
262251
# See https://github.com/NixOS/nix/issues/5687
263-
+ lib.optionalString (atLeast25 && stdenv.hostPlatform.isDarwin) ''
252+
+ lib.optionalString (atLeast224 && stdenv.hostPlatform.isDarwin) ''
264253
echo "exit 99" > tests/gc-non-blocking.sh
265254
'' # TODO: investigate why this broken
266-
+ lib.optionalString (atLeast25 && stdenv.hostPlatform.system == "aarch64-linux") ''
255+
+ lib.optionalString (atLeast224 && stdenv.hostPlatform.system == "aarch64-linux") ''
267256
echo "exit 0" > tests/functional/flakes/show.sh
268257
'' + ''
269258
# nixStatic otherwise does not find its man pages in tests.
270259
export MANPATH=$man/share/man:$MANPATH
271260
'';
272261

273-
separateDebugInfo = stdenv.hostPlatform.isLinux && (atLeast24 -> !enableStatic);
262+
separateDebugInfo = stdenv.hostPlatform.isLinux && (atLeast224 -> !enableStatic);
274263

275264
enableParallelBuilding = true;
276265

0 commit comments

Comments
 (0)