-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
264 lines (232 loc) · 8.37 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
{
description = "Flake for gbs_prism";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
bbmap = {
url = "github:AgResearch/bbmap.nix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
bcl-convert = {
url = "github:AgResearch/bcl-convert.nix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
cutadapt = {
url = "github:AgResearch/cutadapt.nix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
tassel3 = {
url = "github:AgResearch/tassel3/main";
inputs.nixpkgs.follows = "nixpkgs";
};
kgd = {
url = "github:AgResearch/KGD?ref=refs/tags/v1.3.0";
inputs.nixpkgs.follows = "nixpkgs";
};
GUSbase = {
url = "github:tpbilton/GUSbase";
inputs.nixpkgs.follows = "nixpkgs";
};
gquery = {
url = "git+ssh://k-devops-pv01.agresearch.co.nz/tfs/Scientific/Bioinformatics/_git/gquery?ref=refs/heads/main";
inputs.nixpkgs.follows = "nixpkgs";
};
redun = {
# TODO reinstate official release when this is fixed and released:
# https://github.com/insitro/redun/issues/109
url = "github:AgResearch/redun.nix/redun-console-log";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
inputs.flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import inputs.nixpkgs {
inherit system;
};
flakePkgs = {
bbmap = inputs.bbmap.packages.${system}.default;
bcl-convert = inputs.bcl-convert.packages.${system}.default;
cutadapt = inputs.cutadapt.packages.${system}.default;
tassel3 = inputs.tassel3.packages.${system}.default;
kgd-src = inputs.kgd.packages.${system}.src;
GUSbase = inputs.GUSbase.packages.${system}.default;
gquery-api = inputs.gquery.packages.${system}.api;
gquery-cli = inputs.gquery.packages.${system}.cli;
gquery-eri-cli = inputs.gquery.packages.${system}.eri-cli;
};
gquery-export-env = env: inputs.gquery.export-env.${system} env;
gquery-lmod-setenv = inputs.gquery.apps.${system}.lmod-setenv;
# when using NixOS 24.05 we need this:
# https://github.com/NixOS/nixpkgs/issues/308121#issuecomment-2289017641
hatch-fixed = (pkgs.hatch.overrideAttrs (prev: {
disabledTests = prev.disabledTests ++ [
"test_field_readme"
"test_field_string"
"test_field_complex"
"test_new_selected_python"
"test_plugin_dependencies_unmet"
];
}));
gbs-prism-api = with pkgs;
python3Packages.buildPythonPackage {
name = "gbs-prism-api";
src = ./.;
pyproject = true;
nativeBuildInputs = [
hatch-fixed
python3Packages.hatchling
];
propagatedBuildInputs = with python3Packages;
[
biopython
pdf2image
pydantic
flakePkgs.gquery-api
];
};
run_kgd = pkgs.stdenv.mkDerivation {
name = "gbs_prism_kgd";
src = ./src/run_kgd.R;
buildInputs = [ flakePkgs.kgd-src ];
nativeBuildInputs = [ pkgs.makeWrapper ];
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
runHook preInstall
cp $src $out/bin/run_kgd.R
chmod 755 $out/bin/run_kgd.R
runHook postInstall
'';
postFixup = ''
wrapProgram $out/bin/run_kgd.R --set KGD_SRC "${flakePkgs.kgd-src}"
'';
};
R-with-GUSbase = pkgs.rWrapper.override {
packages = [ flakePkgs.GUSbase ];
};
run_GUSbase =
pkgs.stdenv.mkDerivation {
name = "gbs_prism_GUSbase";
src = ./src/run_GUSbase.R;
buildInputs = [ R-with-GUSbase ];
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
runHook preInstall
cp $src $out/bin/run_GUSbase.R
chmod 755 $out/bin/run_GUSbase.R
runHook postInstall
'';
};
redun-with-gbs-prism = inputs.redun.lib.${system}.default {
propagatedBuildInputs = [ gbs-prism-api ];
};
python-with-gbs-prism = pkgs.python3.withPackages (ps: [ gbs-prism-api ]);
# for development, we use a redun with only gquery, and pick up the gbs-prism locally
redun-with-gquery = inputs.redun.lib.${system}.default {
propagatedBuildInputs = with pkgs.python3Packages; [
biopython
pdf2image
pydantic
flakePkgs.gquery-api
];
};
gbs-prism-pipeline = pkgs.symlinkJoin
{
name = "gbs-prism-pipeline";
# the main pipeline.py and all the context files
paths = [
(pkgs.writeTextDir "pipeline/pipeline.py" (builtins.readFile ./pipeline.py))
] ++ pkgs.lib.attrsets.mapAttrsToList
(filename: filetype:
pkgs.writeTextDir "pipeline/${filename}" (builtins.readFile (./context + "/${filename}"))
)
(builtins.readDir ./context);
};
gbs-prism-dependencies = pkgs.symlinkJoin
{
name = "gbs-prism-dependencies";
paths = [
run_kgd
run_GUSbase
] ++ (with flakePkgs; [
bbmap
bcl-convert
cutadapt
tassel3
]) ++ (with pkgs; [
bwa
samtools
fastqc
seqtk
gzip
poppler_utils
]);
};
gbs-prism = pkgs.symlinkJoin
{
name = "gbs-prism";
paths = [
redun-with-gbs-prism
python-with-gbs-prism
gbs-prism-pipeline
gbs-prism-dependencies
flakePkgs.gquery-cli
];
};
eri-install = pkgs.writeShellScriptBin "eri-install.gbs_prism" (builtins.readFile ./eri/install);
in
with pkgs;
{
devShells = {
default = mkShell {
buildInputs =
let
gbs-prism-scripts = pkgs.symlinkJoin
{
name = "gbs-prism-dependencies";
paths = [
(pkgs.writeScriptBin "kmer_prism"
(builtins.readFile ./src/agr/gbs_prism/kmer_prism.py))
(pkgs.writeScriptBin "get_reads_tags_per_sample"
(builtins.readFile ./src/agr/gbs_prism/get_reads_tags_per_sample.py))
(pkgs.writeScriptBin "summarise_read_and_tag_counts"
(builtins.readFile ./src/agr/gbs_prism/summarise_read_and_tag_counts.py))
(pkgs.writeScriptBin "make_cohort_pages"
(builtins.readFile ./src/agr/gbs_prism/make_cohort_pages.py))
];
};
in
[
bashInteractive
redun-with-gquery
gbs-prism-dependencies
gbs-prism-scripts
python3Packages.pytest
];
shellHook = ''
# enable use of gbs_prism from current directory during development
export PYTHONPATH=$(pwd)/src:$PYTHONPATH
${gquery-export-env "dev"}
export GQUERY_ROOT=$HOME/gquery-logs
'';
};
};
packages = {
default = gbs-prism;
};
apps = {
eri-install = {
type = "app";
program = "${eri-install}/bin/eri-install.gbs_prism";
};
# used in eri/install for the module file
lmod-setenv = gquery-lmod-setenv;
};
}
);
}