]> Git — Sourcephile - gargantext.git/blob - flake.nix
build: remove cabal-install and stack config files
[gargantext.git] / flake.nix
1 {
2 # nix flake update or nix flake lock --update-input nixpkgs
3 inputs = {
4 nixpkgs.url = "github:NixOS/nixpkgs/release-23.05";
5 # Or use the the user's/global registry:
6 #nixpkgs.url = "flake:nixpkgs";
7 pre-commit-hooks = {
8 url = "github:cachix/pre-commit-hooks.nix";
9 inputs.nixpkgs.follows = "nixpkgs";
10 inputs.nixpkgs-stable.follows = "nixpkgs";
11 };
12
13 # FIXME: err404
14 #gargantext-prelude.url = "gitlab:gargantext/haskell-gargantext-prelude?host=git.iscpif.fr";
15 gargantext-prelude = { url = "git+https://gitlab.iscpif.fr/cgenie/haskell-gargantext-prelude.git"; flake = false; };
16 # WARNING: using the debugNaN branch
17 gargantext-graph = { url = "git+https://gitlab.iscpif.fr/gargantext/gargantext-graph.git?ref=debugNaN"; flake = false; };
18 hlcm = { url = "git+https://gitlab.iscpif.fr/gargantext/hlcm.git"; flake = false; };
19 rdf4h = { url = "github:robstewart57/rdf4h"; flake = false; };
20 ekg-json = { url = "github:alpmestan/ekg-json"; flake = false; };
21
22 # External Data API connectors
23 crawlerArxiv = { url = "git+https://gitlab.iscpif.fr/gargantext/crawlers/arxiv-api.git?ref=master"; flake = false; };
24 crawlerHAL = { url = "git+https://gitlab.iscpif.fr/gargantext/crawlers/hal.git"; flake = false; };
25 crawlerIsidore = { url = "git+https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git"; flake = false; };
26 crawlerISTEX = { url = "git+https://gitlab.iscpif.fr/gargantext/crawlers/istex.git"; flake = false; };
27 crawlerPubMed = { url = "git+https://gitlab.iscpif.fr/gargantext/crawlers/pubmed.git"; flake = false; };
28 openalex = { url = "git+https://gitlab.iscpif.fr/gargantext/crawlers/openalex.git"; flake = false; };
29
30 # Data Mining Libs
31 data-time-segment = { url = "github:delanoe/data-time-segment"; flake = false; };
32
33 # Graph libs
34 haskell-igraph = { url = "git+https://gitlab.iscpif.fr/gargantext/haskell-igraph.git"; flake = false; };
35 hsinfomap = { url = "git+https://gitlab.iscpif.fr/gargantext/haskell-infomap.git"; flake = false; };
36
37 # NP libs
38 # WARNING: using the 163-fix-transform-with branch
39 patches-class = { url = "git+https://gitlab.iscpif.fr/cgenie/patches-class.git?ref=163-fix-transform-with"; flake = false; };
40 patches-map = { url = "github:delanoe/patches-map"; flake = false; };
41
42 # Accelerate Linear Algebra and specific instances
43 # WARNING: using the dbg branch
44 accelerate = { url = "github:alpmestan/accelerate/dbg"; flake = false; };
45 accelerate-arithmetic = { url = "github:alpmestan/accelerate-arithmetic"; flake = false; };
46 # WARNING: using the fix-error branch
47 accelerate-utility = { url = "git+https://gitlab.iscpif.fr/amestanogullari/accelerate-utility.git?ref=fix-error"; flake = false; };
48 # WARNING: using the dbg branch
49 accelerate-llvm = { url = "github:alpmestan/accelerate-llvm/dbg"; flake = false; };
50 # WARNING: using the alp/imap-static branch
51 hmatrix = { url = "github:alpmestan/hmatrix/alp/imap-static"; flake = false; };
52 # WARNING: using the alp/static branch
53 sparse-linear = { url = "github:alpmestan/sparse-linear/alp/static"; flake = false; };
54 wikiparsec = { url = "github:rspeer/wikiparsec"; flake = false; };
55
56 boolexpr = { url = "github:boolexpr/boolexpr"; flake = false; };
57 # NOTE: Alternative: using flake = true for boolexpr, but quite useless
58 # and painful to configure to avoid downloading/storing extra nixpkgs.
59 # boolexpr = {
60 # url = "github:boolexpr/boolexpr";
61 # inputs.nixpkgs.follows = "nixpkgs";
62 # inputs.flake-parts.follows = "flake-parts";
63 # };
64 # flake-parts = {
65 # url = "github:hercules-ci/flake-parts";
66 # inputs.nixpkgs-lib.follows = "nixpkgs";
67 # };
68
69 # WARNING: using the more-exports branch
70 servant-job = { url = "github:alpmestan/servant-job/more-exports"; flake = false; };
71 };
72 outputs = inputs:
73 let
74 pkg = "gargantext";
75 lib = inputs.nixpkgs.lib;
76 forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f rec {
77 inherit system;
78 pkgs = inputs.nixpkgs.legacyPackages.${system}.extend (finalPkgs: prevPkgs: {
79 # Any overlay for Nixpkgs' pkgs can go here
80 });
81 ghcVersion = "ghc8107";
82 configureFlagsGraphClustering = map (x: "--ghc-option=" + x) [ "-O2" "-fsimpl-tick-factor=10000" "-fdicts-cheap" "-fdicts-strict" "-flate-dmd-anal" "-fno-state-hack" ];
83 haskellPackages = pkgs.haskell.packages.${ghcVersion}.extend (with pkgs.haskell.lib; finalHP: prevHP: {
84 ${pkg} = disableExecutableProfiling (disableLibraryProfiling (overrideCabal
85 (buildFromSdist (finalHP.callCabal2nix pkg inputs.self {
86 # Because haskell-igraph needs that old singletons
87 singletons = finalHP.callHackage "singletons" "2.7" {
88 th-desugar = finalHP.callHackage "th-desugar" "1.11" { };
89 };
90 }))
91 (drv: {
92 testFlags = [
93 "--pattern"
94 (lib.concatStringsSep " && "
95 [
96 # FIXME: FAIL
97 # src-test/Offline/JSON.hs:47:
98 # JSON instance will break frontend!
99 "!/WithQuery frontend compliance/"
100 # FIXME: FAIL (non-deterministic)
101 # expected: ["Job #3","Job #4"]
102 # but got: []
103 "!/respects max runners limit/"
104 # FIXME: FAIL (non-deterministic)
105 # Starting 1 job runners.
106 # Starting 1 job runners.
107 # expected: [Nothing,Just 10,Just 5]
108 # but got: [Nothing,Nothing,Nothing]
109 "!/can fetch the latest job status/"
110 # FIXME: FAIL (non-deterministic)
111 # Starting 1 job runners.
112 # expected: [Just 100]
113 # but got: [Nothing]
114 "!/can spin two separate jobs and track their status separately/"
115 ])
116 ];
117 })));
118
119 accelerate = finalHP.callCabal2nix "accelerate" inputs.accelerate { };
120
121 # Setup: Encountered missing or private dependencies:
122 # accelerate >=1.0 && <1.2
123 accelerate-arithmetic = appendPatch (doJailbreak (finalHP.callCabal2nix "accelerate-arithmetic" inputs.accelerate-arithmetic { }))
124 patches/accelerate-arithmetic/0001-remove-test-using-removed-realBandedGramian.patch;
125
126 accelerate-llvm =
127 overrideCabal (finalHP.callCabal2nix "accelerate-llvm" "${inputs.accelerate-llvm}/accelerate-llvm" { })
128 (drv: {
129 # Give access to accelerate-llvm/LICENSE -> ../LICENSE
130 src = inputs.accelerate-llvm;
131 postUnpack = "sourceRoot=$sourceRoot/accelerate-llvm";
132 });
133
134 accelerate-llvm-native =
135 # nofib-llvm-native: Data.Array.Accelerate: the nofib test-suite has been disabled.
136 # Reinstall package 'accelerate' with '-fnofib' to enable it.
137 dontCheck
138 ((overrideCabal (finalHP.callCabal2nix "accelerate-llvm-native" "${inputs.accelerate-llvm}/accelerate-llvm-native" { })
139 (drv: {
140 # Give access to accelerate-llvm-native/LICENSE -> ../LICENSE
141 src = inputs.accelerate-llvm;
142 postUnpack = "sourceRoot=$sourceRoot/accelerate-llvm-native";
143 patches = [
144 # WARNING: see https://github.com/remiturk/libffi/issues/13
145 patches/accelerate-llvm-native/0001-fix-removed-argInt-by-using-argInt64.patch
146 ];
147 })).overrideAttrs (prevAttrs: {
148 # pkgs/development/haskell-modules/generic-builder.nix
149 # does not pass through patchFlags to mkDerivation...
150 patchFlags = [ "-p2" ];
151 }));
152
153 # Setup: Encountered missing or private dependencies:
154 # accelerate >=1.0 && <1.2
155 accelerate-utility = doJailbreak (finalHP.callCabal2nix "accelerate-utility" inputs.accelerate-utility { });
156
157 boolexpr = finalHP.callCabal2nix "boolexpr" inputs.boolexpr { };
158 #boolexpr = inputs.boolexpr.packages.${system}.default;
159
160 bytestring-csv = unmarkBroken prevHP.bytestring-csv;
161
162 crawlerArxiv = finalHP.callCabal2nix "crawlerArxiv"
163 (pkgs.applyPatches {
164 name = "crawlerArxiv-patched";
165 src = inputs.crawlerArxiv;
166 patches = [ patches/arxiv-api/0001-build-fix-license.patch ];
167 })
168 { };
169
170 crawlerHAL = finalHP.callCabal2nix "crawlerHAL"
171 (pkgs.applyPatches {
172 name = "crawlerHAL-patched";
173 src = inputs.crawlerHAL;
174 patches = [ patches/hal/0001-build-fix-halCrawler-crawlerHAL.patch ];
175 })
176 { };
177
178 crawlerISTEX = finalHP.callCabal2nix "crawlerISTEX" inputs.crawlerISTEX { };
179
180 crawlerIsidore = finalHP.callCabal2nix "crawlerIsidore" inputs.crawlerIsidore { };
181
182 crawlerPubMed = finalHP.callCabal2nix "crawlerHAL"
183 (pkgs.applyPatches {
184 name = "crawlerPubMed-patched";
185 src = inputs.crawlerPubMed;
186 patches = [ patches/crawlerPubMed/0001-fix-test-suite-build-dependencies.patch ];
187 })
188 { };
189
190 data-time-segment = finalHP.callCabal2nix "data-time-segment" inputs.data-time-segment { };
191
192 duckling = overrideCabal
193 (doJailbreak (appendPatches (unmarkBroken prevHP.duckling)
194 [
195 patches/duckling/0001-fix-missing-Eq-Dimension-a-needed-by-recent-hashable.patch
196 patches/duckling/0002-support-and-require-aeson-2.0.patch
197 ]))
198 (drv: {
199 testFlags = [
200 # https://github.com/facebook/duckling/issues/572
201 "--pattern"
202 "!/AF Tests.Corpus Tests/"
203 ];
204 });
205
206 eigen = doJailbreak (unmarkBroken prevHP.eigen);
207
208 # Because of ekg-json
209 # https://github.com/tibbe/ekg/issues/90
210 ekg = doJailbreak (unmarkBroken prevHP.ekg);
211
212 ekg-json = appendPatch (finalHP.callCabal2nix "ekg-json" inputs.ekg-json { })
213 patches/ekg-json/0001-support-and-require-aeson-2.0.patch;
214
215 # Needed for wikiparsec
216 fast-tagsoup-utf8-only = unmarkBroken prevHP.fast-tagsoup-utf8-only;
217
218 gargantext-graph = appendConfigureFlags
219 (
220 (finalHP.callCabal2nix "gargantext-graph" inputs.gargantext-graph {
221 # Because haskell-igraph needs that old singletons
222 singletons = finalHP.callHackage "singletons" "2.7" {
223 th-desugar = finalHP.callHackage "th-desugar" "1.11" { };
224 };
225 })
226 )
227 configureFlagsGraphClustering;
228
229 # test/Spec.hs:1:9: error:
230 # Not in scope: type constructor or class ‘IO’
231 gargantext-prelude = dontCheck (finalHP.callCabal2nix "gargantext-prelude" inputs.gargantext-prelude { });
232
233 ghc-clippy-plugin = doJailbreak (unmarkBroken prevHP.ghc-clippy-plugin);
234
235 haskell-igraph =
236 appendConfigureFlags
237 (
238 (finalHP.callCabal2nix "haskell-igraph" inputs.haskell-igraph {
239 # Avoid cabal2nix to depend on Hackage's igraph (an homonym),
240 # and use instead the C++ igraph.
241 # Also, use the dev output to include the C headers.
242 igraph = pkgs.igraph.dev;
243 # nixpkgs is using singletons-3.0.1
244 singletons = finalHP.callHackage "singletons" "2.7" {
245 th-desugar = finalHP.callHackage "th-desugar" "1.11" { };
246 };
247 })
248 )
249 # Extra include needed because haskell-igraph's cbits
250 # use: #include <igraph.h>
251 # not: #include <igraph/igraph.h>
252 [
253 "--extra-include-dirs=${pkgs.igraph.dev}/include/igraph"
254 ];
255
256 haskell98 = unmarkBroken prevHP.haskell98;
257
258 hlcm = finalHP.callCabal2nix "hlcm" inputs.hlcm { };
259
260 hmatrix = appendConfigureFlags (finalHP.callCabal2nix "hmatrix" "${inputs.hmatrix}/packages/base" { }) configureFlagsGraphClustering;
261
262 hsinfomap = finalHP.callCabal2nix "hsinfomap" inputs.hsinfomap { };
263
264 # tests/Database/HSparql/QueryGeneratorTest.hs:19:10: error:
265 # • Illegal instance declaration for
266 # ‘CreateQuery (Query SelectQuery)’
267 # (All instance types must be of the form (T t1 ... tn)
268 # where T is not a synonym.
269 # Use TypeSynonymInstances if you want to disable this.)
270 hsparql = dontCheck (unmarkBroken prevHP.hsparql);
271
272 llvm-hs = unmarkBroken prevHP.llvm-hs;
273
274 # Dropped support for older GHC, this is the LTS-18.28 version
275 modern-uri = doJailbreak (finalHP.callHackage "modern-uri" "0.3.4.3" { });
276
277 morpheus-graphql-core = unmarkBroken prevHP.morpheus-graphql-core;
278
279 opaleye = appendPatch prevHP.opaleye
280 # [FTS] full text search implementation
281 patches/opaleye/PR-563.patch;
282
283 # Setup: Encountered missing or private dependencies:
284 # aeson >=2.1.2 && <2.2,
285 # conduit >=1.3.5 && <1.4,
286 # http-client-tls >=0.3.6.2 && <0.4,
287 # http-conduit >=2.3.8.2 && <2.4
288 openalex = doJailbreak (finalHP.callCabal2nix "openalex" inputs.openalex { });
289
290 patches-class = appendPatch (finalHP.callCabal2nix "patches-class" inputs.patches-class { })
291 patches/patches-class/0001-fix-comment-that-confused-GHC-because-of-haddock-syn.patch;
292
293 # Setup: Encountered missing or private dependencies:
294 # QuickCheck >=2.7 && <2.14,
295 # doctest >=0.9 && <0.17,
296 # hspec >=2.1 && <2.8
297 # Disable checks because they take too much time and resources
298 patches-map = dontCheck (doJailbreak (finalHP.callCabal2nix "patches-map" inputs.patches-map { }));
299
300 servant-ekg = appendPatch prevHP.servant-ekg
301 patches/servant-ekg/0001-fix-missing-instance-HasEndpoint.patch;
302
303 servant-job = appendPatch (doJailbreak (finalHP.callCabal2nix "servant-job" inputs.servant-job { }))
304 patches/servant-job/0001-fix-comment-breaking-haddock.patch;
305
306 servant-xml = unmarkBroken prevHP.servant-xml;
307
308 # tests/Sparse.hs:195:11: error:
309 # • Expected kind ‘* -> *’, but ‘St.Matrix n p Vector’ has kind ‘*’
310 sparse-linear = dontCheck (appendConfigureFlags (finalHP.callCabal2nix "sparse-linear" (inputs.sparse-linear + "/sparse-linear") { }) configureFlagsGraphClustering);
311
312 # Setup: Encountered missing or private dependencies:
313 # base >=4.0 && <4.10
314 stemmer = doJailbreak (unmarkBroken prevHP.stemmer);
315
316 taggy-lens = unmarkBroken prevHP.taggy-lens;
317
318 # Setup: Encountered missing or private dependencies:
319 # attoparsec ==0.13.*, classy-prelude ==1.4.*, text-icu ==0.7.*
320 wikiparsec = doJailbreak (finalHP.callCabal2nix "wikiparsec" inputs.wikiparsec { });
321
322 # Setup: Encountered missing or private dependencies:
323 # base >=4.16.0 && <4.19, bytestring >=0.11.3 && <0.12
324 wuss = doJailbreak prevHP.wuss;
325
326 });
327 });
328 in
329 rec {
330 # nix -L build
331 defaultPackage = forAllSystems ({ haskellPackages, ... }: haskellPackages.${pkg});
332
333 # For debugging a specific dependency, eg:
334 # nix -L build .#haskellPackages.boolexpr
335 # nix -L develop .#haskellPackages.servant-job
336 # genericBuild
337 packages = forAllSystems ({ pkgs, haskellPackages, ... }: pkgs // { inherit haskellPackages; });
338
339 # nix -L develop or direnv allow
340 devShell = forAllSystems ({ pkgs, haskellPackages, system, ... }:
341 haskellPackages.shellFor {
342 packages = ps: [ ps.${pkg} ];
343 nativeBuildInputs = [
344 haskellPackages.cabal-install
345 haskellPackages.ghcid
346 haskellPackages.haskell-language-server
347 haskellPackages.hlint
348 #haskellPackages.markdown-unlit
349 #haskellPackages.tasty-discover
350 #pkgs.git-chglog
351 pkgs.reuse
352 ];
353 withHoogle = false;
354 inherit (checks.${system}.pre-commit-check) shellHook;
355 });
356
357 # nix flake check
358 checks = forAllSystems (args: with args; {
359 pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
360 src = inputs.self;
361 #settings.ormolu.cabalDefaultExtensions = true;
362 settings.ormolu.defaultExtensions = [
363 "ImportQualifiedPost"
364 "TypeApplications"
365 ];
366 hooks = {
367 #hlint.enable = true;
368 nixpkgs-fmt.enable = true;
369 #fourmolu.enable = true;
370 #cabal-fmt.enable = true;
371 };
372 };
373 });
374 };
375 }