-
Notifications
You must be signed in to change notification settings - Fork 20
/
guix.scm
260 lines (244 loc) · 8.79 KB
/
guix.scm
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
;; To use this file to build a version of wfmash using git HEAD:
;;
;; guix build -f guix.scm # default build
;; guix build -L . wfmash-gcc-git # stanard gcc build
;; guix build -L . wfmash-gcc-debug-git # gcc build with debug and ASAN
;; guix build -L . wfmash-gcc-profile-git # run the profiler!
;; guix build -L . wfmash-static-gcc-git # gcc static build (default)
;; guix build -L . wfmash-clang-git # clang build
;;
;; To get a development container using a recent guix (see `guix pull`)
;;
;; guix shell -C -D -F -f guix.scm # default build
;; guix shell -L . -C -D -F wfmash-gcc-git # preferred development container
;; guix shell -L . -C -D -F wfmash-gcc-static-git
;; guix shell -L . -C -D -F wfmash-clang-git
;;
;; and inside the container
;;
;; mkdir build
;; cd build
;; rm -rf ../build/*
;; cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_OPTIMIZED=1 ..
;; make -j 12 VERBOSE=1
;; ctest . --verbose
;;
;; alternative builds
;;
;; cmake -DCMAKE_BUILD_TYPE=Debug .. # for development (use wfmash-gcc-git)
;; cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. # for distros including Debian (use wfmash-gcc-git)
;; cmake -DBUILD_STATIC=1 .. # static binary (use wfmash-gcc-static-git)
;;
;; list packages
;;
;; guix package -L . -A|grep wfm
;;
;; Installing guix (note that Debian comes with guix). Once installed update as a normal user with:
;;
;; mkdir ~/opt
;; guix pull -p ~/opt/guix # update guix takes a while - don't do this often!
;;
;; Use the update guix to build wfmash:
;;
;; ~/opt/guix/bin/guix build -f guix.scm
;;
;; Or get a shell
;;
;; ~/opt/guix/gin/guix build -f guix.scm
;;
;; If things do not work you may also have to update the guix-daemon in systemd. Guix mostly downloads binary
;; substitutes. If it wants to build a lot of software you probably have substitutes misconfigured.
;; by Pjotr Prins & Andrea Guarracino (c) 2023-2024
(define-module (guix)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cmake)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (gnu packages algebra)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages bioinformatics)
#:use-module (gnu packages build-tools)
#:use-module (gnu packages compression)
#:use-module (gnu packages cpp)
#:use-module (gnu packages gcc)
#:use-module (gnu packages jemalloc)
#:use-module (gnu packages linux) ; for util-linux column
#:use-module (gnu packages llvm)
#:use-module (gnu packages maths)
#:use-module (gnu packages multiprecision)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages version-control)
#:use-module (srfi srfi-1)
#:use-module (ice-9 popen)
#:use-module (ice-9 rdelim))
(define %source-dir (dirname (current-filename)))
(define %git-commit
(read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ)))
(define-public wfmash-base-git
(package
(name "wfmash-base-git")
(version (git-version "0.21" "HEAD" %git-commit))
(source (local-file %source-dir #:recursive? #t))
(build-system cmake-build-system)
(inputs
`(
("bash" ,bash) ; for testing
("bedtools" ,bedtools) ; for testing
("util-linux" ,util-linux) ; for testing
("samtools" ,samtools) ; for testing
("bzip2" ,bzip2)
("coreutils" ,coreutils) ; for echo and env in tests
("git" ,git)
("gmp" ,gmp)
("gsl" ,gsl)
("htslib" ,htslib)
("jemalloc" ,jemalloc)
("libdeflate" ,libdeflate)
("make" ,gnu-make)
("pkg-config" ,pkg-config)
("xz" ,xz)
("zlib" ,zlib)))
(synopsis "wfmash")
(description
"wfmash is an aligner for pangenomes that combines efficient homology
mapping with base-level alignment. It uses MashMap to find approximate
mappings between sequences, then applies WFA (Wave Front Alignment) to
obtain base-level alignments.")
(home-page "https://github.com/waveygang/wfmash")
(license license:expat)))
(define-public wfmash-gcc-git
"Default build with gcc - as is used in distros"
(package
(inherit wfmash-base-git)
(name "wfmash-gcc-git")
(version (git-version "0.21" "HEAD" %git-commit))
(inputs
(modify-inputs (package-inputs wfmash-base-git)
(append gcc-14
)))
))
(define-public wfmash-gcc-debug-git
"Build with debug options"
(package
(inherit wfmash-gcc-git)
(name "wfmash-gcc-debug-git")
(version (git-version "0.21" "HEAD" %git-commit))
(arguments
`(;; #:tests? #f ;; skip tests, this is mostly to run a shell
#:configure-flags
,#~(list
"-DASAN=ON"
"-DDISABLE_LTO=ON"
"-DCMAKE_BUILD_TYPE=Debug"))) ; force cmake static build and do not rewrite RPATH
(inputs
(modify-inputs (package-inputs wfmash-gcc-git)
(append gperftools
)))
))
(define-public wfmash-clang-git
"Clang+LLVM build"
(package
(inherit wfmash-base-git)
(name "wfmash-clang-git")
(version (git-version "0.21" "HEAD" %git-commit))
(inputs
(modify-inputs (package-inputs wfmash-base-git)
(append clang-toolchain-18
lld
libomp
)))
))
(define-public wfmash-gcc-profile-git
"Build wfmash optimally and automatically run profiler on all tests"
(package
(inherit wfmash-gcc-git)
(name "wfmash-gcc-profile-git")
(version (git-version "0.21" "HEAD" %git-commit))
(arguments
`(#:tests? #f ;; running tests as profiler
#:configure-flags
,#~(list
"-DCMAKE_BUILD_TYPE=Release"
"-DBUILD_OPTIMIZED=ON"
"-DPROFILER=ON")
#:phases
,#~(modify-phases %standard-phases
(add-after 'install 'run-profiler-on-all2all
(lambda* (#:key outputs #:allow-other-keys)
(invoke "ctest" "--verbose" "-R" "all2all") ; only run all2all test
(invoke "ls" "-l" "bin/wfmash")
(invoke "ls" "-l")
(invoke "pprof" "--text" "bin/wfmash" "wfmash.prof")
(mkdir-p (string-append #$output:doc "/share")))))))
(inputs
(modify-inputs (package-inputs wfmash-gcc-git)
(append gperftools
coreutils ;; for ls
)))
))
;; ==== The following is for static binary builds using gcc - used mostly for deployment ===
;; Guix does not come with a static version of libdeflate
(define-public libdeflate-static
(package
(inherit libdeflate)
(name "libdeflate-static")
(version "1.19")
(arguments
(list #:configure-flags
#~(list "-DLIBDEFLATE_BUILD_STATIC_LIB=YES"
"-DLIBDEFLATE_BUILD_TESTS=YES")))))
;; A minimal static version of htslib that does not depend on curl and openssl. This
;; reduces the number of higher order dependencies in static linking.
(define-public htslib-static
(package
(inherit htslib)
(name "htslib-static")
(version "1.19")
(source (origin
(method url-fetch)
(uri (string-append
"https://github.com/samtools/htslib/releases/download/"
version "/htslib-" version ".tar.bz2"))
(sha256
(base32
"0dh79lwpspwwfbkmllrrhbk8nkvlfc5b5ib4d0xg5ld79w6c8lc7"))))
(arguments
(substitute-keyword-arguments (package-arguments htslib)
((#:configure-flags flags ''())
''())))
(inputs
(list bzip2 xz))))
(define %source-dir (dirname (current-filename)))
(define %git-commit
(read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ)))
(define-public wfmash-static-gcc-git
"Optimized for latest AMD architecture build and static deployment.
These binaries can be copied to HPC."
(package
(inherit wfmash-base-git)
(name "wfmash-static-gcc-git")
(version (git-version "0.21" "HEAD" %git-commit))
(arguments
`(;; #:tests? #f
#:configure-flags
,#~(list
"-DBUILD_STATIC=ON"
"-DBUILD_OPTIMIZED=ON"
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_RPATH="))) ; force cmake static build and do not rewrite RPATH
(inputs
(modify-inputs (package-inputs wfmash-gcc-git)
(prepend
`(,bzip2 "static")
`(,zlib "static")
`(,gsl "static")
`(,xz "static")
libdeflate-static
htslib-static
)))))
wfmash-static-gcc-git ;; default optimized static deployment build