Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 makeWrapper,
6 openjdk,
7 gradle_8,
8 wget,
9 which,
10 gnused,
11 gawk,
12 coreutils,
13 bash,
14 testers,
15 nixosTests,
16}:
17let
18 # "Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0."
19 gradle = gradle_8;
20in
21stdenv.mkDerivation (finalAttrs: {
22 pname = "nextflow";
23 # 24.08.0-edge is compatible with Java 21. The current (as of 2024-09-19)
24 # nextflow release (24.04.4) does not yet support java21, but java19. The
25 # latter is not in nixpkgs(-unstable) anymore.
26 version = "24.08.0-edge";
27
28 src = fetchFromGitHub {
29 owner = "nextflow-io";
30 repo = "nextflow";
31 rev = "6e866ae81ff3bf8a9729e9dbaa9dd89afcb81a4b";
32 hash = "sha256-SA27cuP3iO5kD6u0uTeEaydyqbyJzOkVtPrb++m3Tv0=";
33 };
34
35 nativeBuildInputs = [
36 makeWrapper
37 gradle
38 ];
39
40 postPatch = ''
41 # Nextflow invokes the constant "/bin/bash" (not as a shebang) at
42 # several locations so we fix that globally. However, when running inside
43 # a container, we actually *want* "/bin/bash". Thus the global fix needs
44 # to be reverted for this specific use case.
45 substituteInPlace modules/nextflow/src/main/groovy/nextflow/executor/BashWrapperBuilder.groovy \
46 --replace-fail "['/bin/bash'," "['${bash}/bin/bash'," \
47 --replace-fail "if( containerBuilder ) {" "if( containerBuilder ) {
48 launcher = launcher.replaceFirst(\"/nix/store/.*/bin/bash\", \"/bin/bash\")"
49 '';
50
51 mitmCache = gradle.fetchDeps {
52 inherit (finalAttrs) pname;
53 data = ./deps.json;
54 };
55 __darwinAllowLocalNetworking = true;
56
57 # During the build, some additional dependencies are downloaded ("detached
58 # configuration"). We thus need to run a full build on instead of the default
59 # one.
60 # See https://github.com/NixOS/nixpkgs/pull/339197#discussion_r1747749061
61 gradleUpdateTask = "pack";
62 # The installer attempts to copy a final JAR to $HOME/.nextflow/...
63 gradleFlags = [ "-Duser.home=\$TMPDIR" ];
64 preBuild = ''
65 # See Makefile (`make pack`)
66 export BUILD_PACK=1
67 '';
68 gradleBuildTask = "pack";
69
70 installPhase = ''
71 runHook preInstall
72
73 mkdir -p $out/bin
74 install -Dm755 build/releases/nextflow-${finalAttrs.version}-dist $out/bin/nextflow
75
76 runHook postInstall
77 '';
78
79 postFixup = ''
80 wrapProgram $out/bin/nextflow \
81 --prefix PATH : ${
82 lib.makeBinPath [
83 coreutils
84 gawk
85 gnused
86 wget
87 which
88 ]
89 } \
90 --set JAVA_HOME ${openjdk.home} \
91 --set NXF_OPTS "-Duser.name=\''${USER}"
92 '';
93
94 passthru.tests.default = nixosTests.nextflow;
95 # versionCheckHook doesn't work as of 2024-09-23.
96 # See https://github.com/NixOS/nixpkgs/pull/339197#issuecomment-2363495060
97 passthru.tests.version = testers.testVersion {
98 package = finalAttrs.finalPackage;
99 command = "env HOME=$TMPDIR nextflow -version";
100 };
101
102 meta = with lib; {
103 description = "DSL for data-driven computational pipelines";
104 longDescription = ''
105 Nextflow is a bioinformatics workflow manager that enables the development of portable and reproducible workflows.
106
107 It supports deploying workflows on a variety of execution platforms including local, HPC schedulers, AWS Batch, Google Cloud Life Sciences, and Kubernetes.
108
109 Additionally, it provides support for manage your workflow dependencies through built-in support for Conda, Docker, Singularity, and Modules.
110 '';
111 homepage = "https://www.nextflow.io/";
112 changelog = "https://github.com/nextflow-io/nextflow/releases";
113 license = licenses.asl20;
114 maintainers = with maintainers; [
115 Etjean
116 edmundmiller
117 ];
118 mainProgram = "nextflow";
119 platforms = platforms.unix;
120 };
121})