Skip to content

Commit cb793d5

Browse files
authored
nextflow: 22.10.6 -> 24.08.0-edge + remove buildFHSEnv + compile from source + add tests (#339197)
2 parents c163396 + f481bad commit cb793d5

File tree

4 files changed

+2166
-40
lines changed

4 files changed

+2166
-40
lines changed

nixos/tests/all-tests.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ in {
658658
# TODO: put in networking.nix after the test becomes more complete
659659
networkingProxy = handleTest ./networking-proxy.nix {};
660660
nextcloud = handleTest ./nextcloud {};
661+
nextflow = handleTestOn ["x86_64-linux"] ./nextflow.nix {};
661662
nextjs-ollama-llm-ui = runTest ./web-apps/nextjs-ollama-llm-ui.nix;
662663
nexus = handleTest ./nexus.nix {};
663664
# TODO: Test nfsv3 + Kerberos

nixos/tests/nextflow.nix

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import ./make-test-python.nix (
2+
{ pkgs, ... }:
3+
let
4+
bash = pkgs.dockerTools.pullImage {
5+
imageName = "quay.io/nextflow/bash";
6+
imageDigest = "sha256:bea0e244b7c5367b2b0de687e7d28f692013aa18970941c7dd184450125163ac";
7+
sha256 = "161s9f24njjx87qrwq0c9nmnwvyc6iblcxka7hirw78lm7i9x4w5";
8+
finalImageName = "quay.io/nextflow/bash";
9+
};
10+
11+
hello = pkgs.stdenv.mkDerivation {
12+
name = "nextflow-hello";
13+
src = pkgs.fetchFromGitHub {
14+
owner = "nextflow-io";
15+
repo = "hello";
16+
rev = "afff16a9b45c8e8a4f5a3743780ac13a541762f8";
17+
hash = "sha256-c8FirHc+J5Y439g0BdHxRtXVrOAzIrGEKA0m1mp9b/U=";
18+
};
19+
installPhase = ''
20+
cp -r $src $out
21+
'';
22+
};
23+
run-nextflow-pipeline = pkgs.writeShellApplication {
24+
name = "run-nextflow-pipeline";
25+
runtimeInputs = [ pkgs.nextflow ];
26+
text = ''
27+
export NXF_OFFLINE=true
28+
for b in false true; do
29+
echo "docker.enabled = $b" > nextflow.config
30+
cat nextflow.config
31+
nextflow run -ansi-log false ${hello}
32+
done
33+
'';
34+
};
35+
in
36+
{
37+
name = "nextflow";
38+
39+
nodes.machine =
40+
{ ... }:
41+
{
42+
environment.systemPackages = [
43+
run-nextflow-pipeline
44+
pkgs.nextflow
45+
];
46+
virtualisation = {
47+
docker.enable = true;
48+
};
49+
};
50+
51+
testScript =
52+
{ nodes, ... }:
53+
''
54+
start_all()
55+
machine.wait_for_unit("docker.service")
56+
machine.succeed("docker load < ${bash}")
57+
machine.succeed("run-nextflow-pipeline >&2")
58+
'';
59+
}
60+
)
Lines changed: 79 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,99 @@
1-
{ lib
2-
, stdenv
3-
, fetchurl
4-
, makeWrapper
5-
, openjdk17
6-
, wget
7-
, which
8-
, gnused
9-
, gawk
10-
, coreutils
11-
, buildFHSEnv
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
makeWrapper,
6+
openjdk,
7+
gradle,
8+
wget,
9+
which,
10+
gnused,
11+
gawk,
12+
coreutils,
13+
bash,
14+
testers,
15+
nixosTests,
1216
}:
13-
14-
let
15-
nextflow =
16-
stdenv.mkDerivation rec {
17+
stdenv.mkDerivation (finalAttrs: {
1718
pname = "nextflow";
18-
version = "22.10.6";
19+
# 24.08.0-edge is compatible with Java 21. The current (as of 2024-09-19)
20+
# nextflow release (24.04.4) does not yet support java21, but java19. The
21+
# latter is not in nixpkgs(-unstable) anymore.
22+
version = "24.08.0-edge";
1923

20-
src = fetchurl {
21-
url = "https://github.com/nextflow-io/nextflow/releases/download/v${version}/nextflow-${version}-all";
22-
hash = "sha256-zeYsKxWRnzr0W6CD+yjoAXwCN/AbN5P4HhH1oftnrjY=";
24+
src = fetchFromGitHub {
25+
owner = "nextflow-io";
26+
repo = "nextflow";
27+
rev = "6e866ae81ff3bf8a9729e9dbaa9dd89afcb81a4b";
28+
hash = "sha256-SA27cuP3iO5kD6u0uTeEaydyqbyJzOkVtPrb++m3Tv0=";
2329
};
2430

2531
nativeBuildInputs = [
2632
makeWrapper
27-
openjdk17
28-
wget
29-
which
30-
gnused
31-
gawk
32-
coreutils
33+
gradle
3334
];
3435

35-
dontUnpack = true;
36+
postPatch = ''
37+
# Nextflow invokes the constant "/bin/bash" (not as a shebang) at
38+
# several locations so we fix that globally. However, when running inside
39+
# a container, we actually *want* "/bin/bash". Thus the global fix needs
40+
# to be reverted for this specific use case.
41+
substituteInPlace modules/nextflow/src/main/groovy/nextflow/executor/BashWrapperBuilder.groovy \
42+
--replace-fail "['/bin/bash'," "['${bash}/bin/bash'," \
43+
--replace-fail "if( containerBuilder ) {" "if( containerBuilder ) {
44+
launcher = launcher.replaceFirst(\"/nix/store/.*/bin/bash\", \"/bin/bash\")"
45+
'';
46+
47+
mitmCache = gradle.fetchDeps {
48+
inherit (finalAttrs) pname;
49+
data = ./deps.json;
50+
};
51+
__darwinAllowLocalNetworking = true;
52+
53+
# During the build, some additional dependencies are downloaded ("detached
54+
# configuration"). We thus need to run a full build on instead of the default
55+
# one.
56+
# See https://github.com/NixOS/nixpkgs/pull/339197#discussion_r1747749061
57+
gradleUpdateTask = "pack";
58+
# The installer attempts to copy a final JAR to $HOME/.nextflow/...
59+
gradleFlags = ["-Duser.home=\$TMPDIR"];
60+
preBuild = ''
61+
# See Makefile (`make pack`)
62+
export BUILD_PACK=1
63+
'';
64+
gradleBuildTask = "pack";
3665

3766
installPhase = ''
3867
runHook preInstall
3968
4069
mkdir -p $out/bin
41-
install -Dm755 $src $out/bin/nextflow
70+
install -Dm755 build/releases/nextflow-${finalAttrs.version}-dist $out/bin/nextflow
4271
4372
runHook postInstall
4473
'';
4574

4675
postFixup = ''
4776
wrapProgram $out/bin/nextflow \
48-
--prefix PATH : ${lib.makeBinPath nativeBuildInputs} \
49-
--set JAVA_HOME ${openjdk17.home}
77+
--prefix PATH : ${
78+
lib.makeBinPath [
79+
coreutils
80+
gawk
81+
gnused
82+
wget
83+
which
84+
]
85+
} \
86+
--set JAVA_HOME ${openjdk.home}
5087
'';
5188

89+
passthru.tests.default = nixosTests.nextflow;
90+
# versionCheckHook doesn't work as of 2024-09-23.
91+
# See https://github.com/NixOS/nixpkgs/pull/339197#issuecomment-2363495060
92+
passthru.tests.version = testers.testVersion {
93+
package = finalAttrs.finalPackage;
94+
command = "env HOME=$TMPDIR nextflow -version";
95+
};
96+
5297
meta = with lib; {
5398
description = "DSL for data-driven computational pipelines";
5499
longDescription = ''
@@ -61,17 +106,11 @@ stdenv.mkDerivation rec {
61106
homepage = "https://www.nextflow.io/";
62107
changelog = "https://github.com/nextflow-io/nextflow/releases";
63108
license = licenses.asl20;
64-
maintainers = with maintainers; [ Etjean edmundmiller ];
109+
maintainers = with maintainers; [
110+
Etjean
111+
edmundmiller
112+
];
65113
mainProgram = "nextflow";
66114
platforms = platforms.unix;
67115
};
68-
};
69-
in
70-
if stdenv.hostPlatform.isLinux then
71-
buildFHSEnv
72-
{
73-
name = "nextflow";
74-
targetPkgs = pkgs: [ nextflow ];
75-
runScript = "nextflow";
76-
}
77-
else nextflow
116+
})

0 commit comments

Comments
 (0)