[nix] flake.nix julm branch merge with dev 0.0.7

parent 1b3b917c
...@@ -29,7 +29,7 @@ source-repository-package ...@@ -29,7 +29,7 @@ source-repository-package
source-repository-package source-repository-package
type: git type: git
location: https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git location: https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git
tag: cb07b604bfb7a22aa21dd8918de5cb65c8a4bdf1 tag: 2ca9f8a80881275dbf7f8816df592f4418797d59
source-repository-package source-repository-package
type: git type: git
...@@ -124,7 +124,7 @@ source-repository-package ...@@ -124,7 +124,7 @@ source-repository-package
type: git type: git
location: https://gitlab.iscpif.fr/gargantext/haskell-gargantext-prelude location: https://gitlab.iscpif.fr/gargantext/haskell-gargantext-prelude
-- tag: 618f711a530df56caefbb1577c4bf3d5ff45e214 -- tag: 618f711a530df56caefbb1577c4bf3d5ff45e214
tag: d4f9bee483d41bbdf8ab4e09efb5a5a8216edff4 tag: 618f711a530df56caefbb1577c4bf3d5ff45e214
source-repository-package source-repository-package
type: git type: git
......
...@@ -86,16 +86,15 @@ ...@@ -86,16 +86,15 @@
"boolexpr": { "boolexpr": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1694500292, "lastModified": 1697119510,
"narHash": "sha256-0Ut4QJVD2ocsUxMVDm9uCp/O3ICPdxVrIrjFcdvOtJ4=", "narHash": "sha256-0Ut4QJVD2ocsUxMVDm9uCp/O3ICPdxVrIrjFcdvOtJ4=",
"owner": "adinapoli", "owner": "boolexpr",
"repo": "boolexpr", "repo": "boolexpr",
"rev": "91928b5d7f9342e9865dde0d94862792d2b88779", "rev": "bcd7cb20a1b1bc3b58c4ba1b6ae1bccfe62f67ae",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "adinapoli", "owner": "boolexpr",
"ref": "adinapoli/term-parsing",
"repo": "boolexpr", "repo": "boolexpr",
"type": "github" "type": "github"
} }
...@@ -186,11 +185,11 @@ ...@@ -186,11 +185,11 @@
"crawlerHAL": { "crawlerHAL": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1702295464, "lastModified": 1710761107,
"narHash": "sha256-VTMSkMPuw4023k4RZtXU9EsV64mKWiXC3qPUUTj/eXE=", "narHash": "sha256-gV2aWfbUcI2mWSVWtbo9SBMXCkkVQQ9ezn4yw0Qv3uw=",
"ref": "refs/heads/master", "ref": "refs/heads/master",
"rev": "bfa9069b4ff70f341ca3244e8aff9e83eb4b8b73", "rev": "b99b9e568c8bdc73af2b8016ed03ba5ee83c2030",
"revCount": 59, "revCount": 61,
"type": "git", "type": "git",
"url": "https://gitlab.iscpif.fr/gargantext/crawlers/hal.git" "url": "https://gitlab.iscpif.fr/gargantext/crawlers/hal.git"
}, },
...@@ -498,23 +497,6 @@ ...@@ -498,23 +497,6 @@
"url": "https://gitlab.iscpif.fr/gargantext/haskell-infomap.git" "url": "https://gitlab.iscpif.fr/gargantext/haskell-infomap.git"
} }
}, },
"haskell-opaleye": {
"flake": false,
"locked": {
"lastModified": 1707909910,
"narHash": "sha256-H79yYmdw9+z2ZkTS7pkjHNgjSQm0MCnPBHhqw65rAaA=",
"owner": "garganscript",
"repo": "haskell-opaleye",
"rev": "6cf1bcfe215143efac17919cfd0abdd60e0f717c",
"type": "github"
},
"original": {
"owner": "garganscript",
"ref": "tsquery-fixes",
"repo": "haskell-opaleye",
"type": "github"
}
},
"haskellNix": { "haskellNix": {
"inputs": { "inputs": {
"HTTP": "HTTP", "HTTP": "HTTP",
...@@ -1039,15 +1021,32 @@ ...@@ -1039,15 +1021,32 @@
"type": "github" "type": "github"
} }
}, },
"opaleye-textsearch": {
"flake": false,
"locked": {
"lastModified": 1713353625,
"narHash": "sha256-WRfcdclyoulri+q+bjQEBeWV75CLCrWNafUeRx0NyxY=",
"ref": "refs/heads/main",
"rev": "2ca9f8a80881275dbf7f8816df592f4418797d59",
"revCount": 5,
"type": "git",
"url": "https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git"
},
"original": {
"type": "git",
"url": "https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git"
}
},
"openalex": { "openalex": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1707164593, "lastModified": 1709630330,
"narHash": "sha256-muuSirbnKslm9UoDtz1EICjLDLHG/YmNZ/vrwa5xGf4=", "narHash": "sha256-TOoyX/jnwpo8wq5gnDG9k5NMERtJAGbBEn3T693zMEM=",
"rev": "cd179f6dda15d77a085c0176284c921b7bc50c46", "ref": "refs/heads/main",
"revCount": 14, "rev": "ceb8f2cebd4890b6d9d151ab01ee14e925bc0499",
"revCount": 18,
"type": "git", "type": "git",
"url": "https://gitlab.iscpif.fr/gargantext/crawlers/openalex.git/" "url": "https://gitlab.iscpif.fr/gargantext/crawlers/openalex.git"
}, },
"original": { "original": {
"type": "git", "type": "git",
...@@ -1124,7 +1123,6 @@ ...@@ -1124,7 +1123,6 @@
"gargantext-prelude": "gargantext-prelude", "gargantext-prelude": "gargantext-prelude",
"haskell-igraph": "haskell-igraph", "haskell-igraph": "haskell-igraph",
"haskell-infomap": "haskell-infomap", "haskell-infomap": "haskell-infomap",
"haskell-opaleye": "haskell-opaleye",
"haskellNix": "haskellNix", "haskellNix": "haskellNix",
"hlcm": "hlcm", "hlcm": "hlcm",
"hmatrix": "hmatrix", "hmatrix": "hmatrix",
...@@ -1134,6 +1132,7 @@ ...@@ -1134,6 +1132,7 @@
"haskellNix", "haskellNix",
"nixpkgs-unstable" "nixpkgs-unstable"
], ],
"opaleye-textsearch": "opaleye-textsearch",
"openalex": "openalex", "openalex": "openalex",
"patches-class": "patches-class", "patches-class": "patches-class",
"patches-map": "patches-map", "patches-map": "patches-map",
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
# To use this Nix flake you may need to enable Nix flake support for your user with: # To use this Nix flake you may need to enable Nix flake support for your user with:
# echo >>~/.config/nix/nix.conf "experimental-features = nix-command flakes" # echo >>~/.config/nix/nix.conf "experimental-features = nix-command flakes"
# To update individual package, look up flake.lock, also you can run:
# nix flake lock --update-input haskell-gargantext-prelude
inputs = { inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix"; haskellNix.url = "github:input-output-hk/haskell.nix";
...@@ -60,11 +63,15 @@ ...@@ -60,11 +63,15 @@
# WARNING: fork of https://github.com/boolexpr/boolexpr # WARNING: fork of https://github.com/boolexpr/boolexpr
# WARNING: was merged upstream # WARNING: was merged upstream
boolexpr = { url = "github:adinapoli/boolexpr/adinapoli/term-parsing"; flake = false; }; #boolexpr = { url = "github:adinapoli/boolexpr/adinapoli/term-parsing"; flake = false; };
boolexpr = { url = "github:boolexpr/boolexpr"; flake = false; };
# WARNING: fork of https://github.com/tomjaguarpaw/haskell-opaleye # WARNING: fork of https://github.com/tomjaguarpaw/haskell-opaleye
# Tracked in: https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/317 # Tracked in: https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/317
haskell-opaleye = { url = "github:garganscript/haskell-opaleye/tsquery-fixes"; flake = false; }; #haskell-opaleye = { url = "github:garganscript/haskell-opaleye/tsquery-fixes"; flake = false; };
#haskell-opaleye = { url = "github:tomjaguarpaw/haskell-opaleye?ref=version_0.9.6.1"; flake = false; };
opaleye-textsearch = { url = "git+https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git"; flake = false; };
# WARNING: using the more-exports branch # WARNING: using the more-exports branch
servant-job = { url = "github:alpmestan/servant-job/more-exports"; flake = false; }; servant-job = { url = "github:alpmestan/servant-job/more-exports"; flake = false; };
...@@ -102,251 +109,255 @@ ...@@ -102,251 +109,255 @@
"aarch64-darwin" "aarch64-darwin"
]; ];
in in
inputs.flake-utils.lib.eachSystem supportedSystems (system: inputs.flake-utils.lib.eachSystem supportedSystems (system:
let let
pkgs = import inputs.nixpkgs { pkgs = import inputs.nixpkgs {
inherit system; inherit system;
config = inputs.haskellNix.config; config = inputs.haskellNix.config;
overlays = [ overlays = [
inputs.haskellNix.overlay inputs.haskellNix.overlay
(finalPkgs: previousPkgs: { (finalPkgs: previousPkgs: {
graphviz = previousPkgs.graphviz.overrideAttrs (finalAttrs: previousAttrs: { graphviz = previousPkgs.graphviz.overrideAttrs (finalAttrs: previousAttrs: {
patches = (previousAttrs.patches or [ ]) ++ [ patches = (previousAttrs.patches or [ ]) ++ [
# Increase the YY_BUF_SIZE # Increase the YY_BUF_SIZE
# See https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/290#note_9015 # See https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/290#note_9015
patches/graphviz/graphviz-yy-buf-size.diff patches/graphviz/graphviz-yy-buf-size.diff
]; ];
}); });
}) })
]; ];
}; };
# A library of very basic Nix expressions. # A library of very basic Nix expressions.
lib = inputs.nixpkgs.lib; lib = inputs.nixpkgs.lib;
# A library of Nix expressions internal to haskell.nix. # A library of Nix expressions internal to haskell.nix.
inherit (pkgs.haskell-nix) haskellLib; inherit (pkgs.haskell-nix) haskellLib;
# Pinning the index-state of Hackage, # Pinning the index-state of Hackage,
# instead of using the latest known by haskell.nix, # instead of using the latest known by haskell.nix,
# removes haskell.nix from interfering too much into the reproducibility. # removes haskell.nix from interfering too much into the reproducibility.
# It also enables to materialize the plan-nix. # It also enables to materialize the plan-nix.
index-state = haskellLib.parseIndexState (lib.readFile ./cabal.project); index-state = haskellLib.parseIndexState (lib.readFile ./cabal.project);
compiler-nix-name = "ghc947"; compiler-nix-name = "ghc947";
# nix-tools/nix-tools/cabal2nix/Main.hs findCabalFiles # nix-tools/nix-tools/cabal2nix/Main.hs findCabalFiles
# always prefers package.yaml over *.cabal, # always prefers package.yaml over *.cabal,
# but when the resulting cabal file is different # but when the resulting cabal file is different
# than a previously existing one, # than a previously existing one,
# the build fails with an error like this one: # the build fails with an error like this one:
# crawlerIsidore.cabal was modified manually, please use --force to overwrite. # crawlerIsidore.cabal was modified manually, please use --force to overwrite.
# Hence just remove this out-of-sync package.yaml. # Hence just remove this out-of-sync package.yaml.
removePackageYaml = src: pkgs.symlinkJoin { removePackageYaml = src: pkgs.symlinkJoin {
name = "removePackageYaml-patched"; name = "removePackageYaml-patched";
paths = [ src ]; paths = [ src ];
postBuild = "rm $out/package.yaml"; postBuild = "rm $out/package.yaml";
};
# haskell.nix's main entry point
project = pkgs.haskell-nix.cabalProject' {
name = "gargantext";
src = ./.;
# By default plan evaluation is done on the build system.
#evalSystem = "x86_64-linux";
inherit compiler-nix-name;
inherit index-state;
# Materializing a project means recording
# the nix files generated from the .cabal et al. files.
# To update:
# $ nix run .#update-nix-cache-plan
#materialized = nix/cache/plan;
#compilerSelection = p: p.haskell.compiler;
# Using inputMap for each source-repository-package of cabal.project
# leverages `nix flake` to get their sha256 hashes
# and check upstreams for updates.
inputMap = {
"https://github.com/AccelerateHS/accelerate-llvm.git" = inputs.accelerate-llvm;
"https://github.com/AccelerateHS/accelerate.git" = inputs.accelerate;
"https://github.com/MercuryTechnologies/ekg-json.git" = inputs.ekg-json;
#"https://github.com/adinapoli/boolexpr.git" = inputs.boolexpr;
"https://github.com/boolexpr/boolexpr.git" = inputs.boolexpr;
"https://github.com/adinapoli/duckling.git" = inputs.duckling;
"https://github.com/adinapoli/llvm-hs.git" = inputs.llvm-hs;
"https://github.com/adinapoli/text16-compat.git" = inputs.text16-compat;
"https://github.com/adinapoli/wikiparsec.git" = inputs.wikiparsec;
"https://github.com/alpmestan/accelerate-arithmetic.git" = inputs.accelerate-arithmetic;
"https://github.com/alpmestan/hmatrix.git" = inputs.hmatrix;
"https://github.com/alpmestan/servant-job.git" = inputs.servant-job;
"https://github.com/alpmestan/sparse-linear.git" = inputs.sparse-linear;
"https://github.com/chessai/eigen.git" = inputs.eigen;
"https://github.com/delanoe/data-time-segment.git" = inputs.data-time-segment;
"https://github.com/delanoe/patches-map" = inputs.patches-map;
#"https://github.com/garganscript/haskell-opaleye.git" = inputs.haskell-opaleye;
"https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git" = inputs.opaleye-textsearch;
"https://github.com/robstewart57/rdf4h.git" = inputs.rdf4h;
"https://gitlab.iscpif.fr/amestanogullari/accelerate-utility.git" = inputs.accelerate-utility;
"https://gitlab.iscpif.fr/gargantext/crawlers/arxiv-api.git" = inputs.crawlerArxiv;
"https://gitlab.iscpif.fr/gargantext/crawlers/epo-proxy-api.git" = inputs.epo-api-client;
"https://gitlab.iscpif.fr/gargantext/crawlers/hal.git" = inputs.crawlerHAL;
"https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git" = inputs.crawlerIsidore;
"https://gitlab.iscpif.fr/gargantext/crawlers/istex.git" = inputs.crawlerISTEX;
"https://gitlab.iscpif.fr/gargantext/crawlers/openalex.git" = inputs.openalex;
"https://gitlab.iscpif.fr/gargantext/crawlers/pubmed.git" = inputs.crawlerPubMed;
"https://gitlab.iscpif.fr/gargantext/gargantext-graph.git" = inputs.gargantext-graph;
"https://gitlab.iscpif.fr/gargantext/haskell-gargantext-prelude" = inputs.gargantext-prelude;
"https://gitlab.iscpif.fr/gargantext/haskell-igraph.git" = inputs.haskell-igraph;
"https://gitlab.iscpif.fr/gargantext/haskell-infomap.git" = inputs.haskell-infomap;
"https://gitlab.iscpif.fr/gargantext/hlcm.git" = inputs.hlcm;
"https://gitlab.iscpif.fr/gargantext/iso639.git" = inputs.iso639;
"https://gitlab.iscpif.fr/gargantext/patches-class.git" = inputs.patches-class;
"https://gitlab.iscpif.fr/gargantext/servant-xml-conduit.git" = inputs.servant-xml-conduit;
# Fixes needed for specific revisions
# ===================================
"https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git/e9b594a4718acc06db037f6d3f429a90db76c267" = removePackageYaml inputs.crawlerIsidore;
"https://gitlab.iscpif.fr/gargantext/haskell-gargantext-prelude/d4f9bee483d41bbdf8ab4e09efb5a5a8216edff4" = removePackageYaml inputs.gargantext-prelude;
"https://gitlab.iscpif.fr/gargantext/crawlers/istex.git/c0a08d62c40a169b7934ceb7cb12c39952160e7a" = removePackageYaml inputs.crawlerISTEX;
"https://github.com/alpmestan/accelerate-arithmetic.git/a110807651036ca2228a76507ee35bbf7aedf87a" = pkgs.applyPatches {
name = "accelerate-arithmetic-patched";
src = inputs.accelerate-arithmetic;
patches = [ patches/accelerate-arithmetic/0001-remove-test-using-removed-realBandedGramian.patch ];
};
}; };
# haskell.nix's main entry point # Default project configuration.
project = pkgs.haskell-nix.cabalProject' { modules = [
name = "gargantext"; {
src = ./.; packages.haskell-igraph.components.library = {
# The generated plan includes pkgs.igraph
# By default plan evaluation is done on the build system. # but pkgs.igraph.dev is also needed for igraph.h
#evalSystem = "x86_64-linux"; libs = [ pkgs.igraph.dev ];
inherit compiler-nix-name; # Extra include needed because haskell-igraph's cbits
inherit index-state; # use: #include <igraph.h>
# not: #include <igraph/igraph.h>
# Materializing a project means recording configureFlags = [ "--extra-include-dirs=${pkgs.igraph.dev}/include/igraph" ];
# the nix files generated from the .cabal et al. files.
# To update:
# $ nix run .#update-nix-cache-plan
#materialized = nix/cache/plan;
#compilerSelection = p: p.haskell.compiler;
# Using inputMap for each source-repository-package of cabal.project
# leverages `nix flake` to get their sha256 hashes
# and check upstreams for updates.
inputMap = {
"https://github.com/AccelerateHS/accelerate-llvm.git" = inputs.accelerate-llvm;
"https://github.com/AccelerateHS/accelerate.git" = inputs.accelerate;
"https://github.com/MercuryTechnologies/ekg-json.git" = inputs.ekg-json;
"https://github.com/adinapoli/boolexpr.git" = inputs.boolexpr;
"https://github.com/adinapoli/duckling.git" = inputs.duckling;
"https://github.com/adinapoli/llvm-hs.git" = inputs.llvm-hs;
"https://github.com/adinapoli/text16-compat.git" = inputs.text16-compat;
"https://github.com/adinapoli/wikiparsec.git" = inputs.wikiparsec;
"https://github.com/alpmestan/accelerate-arithmetic.git" = inputs.accelerate-arithmetic;
"https://github.com/alpmestan/hmatrix.git" = inputs.hmatrix;
"https://github.com/alpmestan/servant-job.git" = inputs.servant-job;
"https://github.com/alpmestan/sparse-linear.git" = inputs.sparse-linear;
"https://github.com/chessai/eigen.git" = inputs.eigen;
"https://github.com/delanoe/data-time-segment.git" = inputs.data-time-segment;
"https://github.com/delanoe/patches-map" = inputs.patches-map;
"https://github.com/garganscript/haskell-opaleye.git" = inputs.haskell-opaleye;
"https://github.com/robstewart57/rdf4h.git" = inputs.rdf4h;
"https://gitlab.iscpif.fr/amestanogullari/accelerate-utility.git" = inputs.accelerate-utility;
"https://gitlab.iscpif.fr/gargantext/crawlers/arxiv-api.git" = inputs.crawlerArxiv;
"https://gitlab.iscpif.fr/gargantext/crawlers/epo-proxy-api.git" = inputs.epo-api-client;
"https://gitlab.iscpif.fr/gargantext/crawlers/hal.git" = inputs.crawlerHAL;
"https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git" = inputs.crawlerIsidore;
"https://gitlab.iscpif.fr/gargantext/crawlers/istex.git" = inputs.crawlerISTEX;
"https://gitlab.iscpif.fr/gargantext/crawlers/openalex.git" = inputs.openalex;
"https://gitlab.iscpif.fr/gargantext/crawlers/pubmed.git" = inputs.crawlerPubMed;
"https://gitlab.iscpif.fr/gargantext/gargantext-graph.git" = inputs.gargantext-graph;
"https://gitlab.iscpif.fr/gargantext/haskell-gargantext-prelude" = inputs.gargantext-prelude;
"https://gitlab.iscpif.fr/gargantext/haskell-igraph.git" = inputs.haskell-igraph;
"https://gitlab.iscpif.fr/gargantext/haskell-infomap.git" = inputs.haskell-infomap;
"https://gitlab.iscpif.fr/gargantext/hlcm.git" = inputs.hlcm;
"https://gitlab.iscpif.fr/gargantext/iso639.git" = inputs.iso639;
"https://gitlab.iscpif.fr/gargantext/patches-class.git" = inputs.patches-class;
"https://gitlab.iscpif.fr/gargantext/servant-xml-conduit.git" = inputs.servant-xml-conduit;
# Fixes needed for specific revisions
# ===================================
"https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git/e9b594a4718acc06db037f6d3f429a90db76c267" = removePackageYaml inputs.crawlerIsidore;
"https://gitlab.iscpif.fr/gargantext/haskell-gargantext-prelude/618f711a530df56caefbb1577c4bf3d5ff45e214" = removePackageYaml inputs.gargantext-prelude;
"https://gitlab.iscpif.fr/gargantext/crawlers/istex.git/c0a08d62c40a169b7934ceb7cb12c39952160e7a" = removePackageYaml inputs.crawlerISTEX;
"https://github.com/alpmestan/accelerate-arithmetic.git/a110807651036ca2228a76507ee35bbf7aedf87a" = pkgs.applyPatches {
name = "accelerate-arithmetic-patched";
src = inputs.accelerate-arithmetic;
patches = [ patches/accelerate-arithmetic/0001-remove-test-using-removed-realBandedGramian.patch ];
}; };
}
];
# Variants to the default project configuration above.
# They're accessed in the flake's outputs with their name prefixed.
# $ nix -L build .#static-x86_64-unknown-linux-musl:gargantext:exe:gargantext-phylo-profile
# Or via project.projectCross:
# $ nix -L build .#project.projectVariants.static.projectCross.musl64.hsPkgs.postgresql-libpq.components.library
flake.variants = {
profiled = {
modules = [
{
# Applies to all packages of the Haskell closure. For instance:
# $ nix eval .#project.hsPkgs.containers.components.library.config.enableProfiling
# false
# $ nix eval .#project.projectVariants.profiled.hsPkgs.containers.components.library.config.enableProfiling
# true
enableProfiling = true;
enableLibraryProfiling = true;
}
];
}; };
# Default project configuration. # For building static executables:
modules = [
{
packages.haskell-igraph.components.library = {
# The generated plan includes pkgs.igraph
# but pkgs.igraph.dev is also needed for igraph.h
libs = [ pkgs.igraph.dev ];
# Extra include needed because haskell-igraph's cbits
# use: #include <igraph.h>
# not: #include <igraph/igraph.h>
configureFlags = [ "--extra-include-dirs=${pkgs.igraph.dev}/include/igraph" ];
};
}
];
# Variants to the default project configuration above.
# They're accessed in the flake's outputs with their name prefixed.
# $ nix -L build .#static-x86_64-unknown-linux-musl:gargantext:exe:gargantext-phylo-profile # $ nix -L build .#static-x86_64-unknown-linux-musl:gargantext:exe:gargantext-phylo-profile
# Or via project.projectCross: #
# $ nix -L build .#project.projectVariants.static.projectCross.musl64.hsPkgs.postgresql-libpq.components.library # Note the use of the Musl cross compiling platform
flake.variants = { # to replace glibc which does not fully support static linking.
profiled = { #
modules = [ # For debugging static executables (Musl is not bug-to-bug compatible with glibc):
{ # $ nix -L develop .#static-x86_64-unknown-linux-musl:gargantext:exe:gargantext-phylo-profile
# Applies to all packages of the Haskell closure. For instance: # [nix-shell] $ rm -rf source outputs
# $ nix eval .#project.hsPkgs.containers.components.library.config.enableProfiling # [nix-shell] $ genericBuild # may fail at some point depending on the bug
# false # [nix-shell] $ cd source
# $ nix eval .#project.projectVariants.profiled.hsPkgs.containers.components.library.config.enableProfiling # [nix-shell] $ eval "$configurePhase"
# true # [nix-shell] $ eval "$buildPhase"
enableProfiling = true; # [nix-shell] $ (unset LD_LIBRARY_PATH; $EDITOR **/*.hs) # hack hack hack
enableLibraryProfiling = true; # [nix-shell] $ eval "$buildPhase"
} # [nix-shell] $ eval "$installPhase"
]; #
}; # See also https://github.com/nh2/static-haskell-nix # which:
# > contains a large amount of per-package fixes for static builds
# For building static executables: # > for which we haven't found a way to integrate them cleanly into nixpkgs yet
# $ nix -L build .#static-x86_64-unknown-linux-musl:gargantext:exe:gargantext-phylo-profile static = {
# modules = [
# Note the use of the Musl cross compiling platform {
# to replace glibc which does not fully support static linking. enableStatic = true;
# #enableShared = false;
# For debugging static executables (Musl is not bug-to-bug compatible with glibc):
# $ nix -L develop .#static-x86_64-unknown-linux-musl:gargantext:exe:gargantext-phylo-profile # Musl does not provide the thread-safe random_r()/initstate_r()
# [nix-shell] $ rm -rf source outputs # so make randomVector fallback to a **non** thread-safe alternative, nrand48()
# [nix-shell] $ genericBuild # may fail at some point depending on the bug # See https://github.com/haskell-numerics/hmatrix/issues/279
# [nix-shell] $ cd source #
# [nix-shell] $ eval "$configurePhase" # As a consequence, random numbers may not be random between threads
# [nix-shell] $ eval "$buildPhase" # as they now share a common state.
# [nix-shell] $ (unset LD_LIBRARY_PATH; $EDITOR **/*.hs) # hack hack hack # See http://www.evanjones.ca/random-thread-safe.html
# [nix-shell] $ eval "$buildPhase" # > the best solution for truly portable applications
# [nix-shell] $ eval "$installPhase" # > is to include your own random number generator implementation,
# # > and not rely on the system's C library.
# See also https://github.com/nh2/static-haskell-nix # which: # See https://github.com/haskell-numerics/hmatrix/issues/307
# > contains a large amount of per-package fixes for static builds packages.hmatrix.flags.no-random_r = true;
# > for which we haven't found a way to integrate them cleanly into nixpkgs yet
static = { # Use pkg-config instead of pg_config to avoid:
modules = [ # $ nix -L build .#legacyPackages.x86_64-linux.project.projectVariants.static.projectCross.musl64.hsPkgs.postgresql-libpq.components.library
{ # > Error: Setup: The program 'pg_config' is required but it could not be found
enableStatic = true; packages.postgresql-libpq.flags.use-pkg-config = true;
#enableShared = false; }
];
# Musl does not provide the thread-safe random_r()/initstate_r()
# so make randomVector fallback to a **non** thread-safe alternative, nrand48()
# See https://github.com/haskell-numerics/hmatrix/issues/279
#
# As a consequence, random numbers may not be random between threads
# as they now share a common state.
# See http://www.evanjones.ca/random-thread-safe.html
# > the best solution for truly portable applications
# > is to include your own random number generator implementation,
# > and not rely on the system's C library.
# See https://github.com/haskell-numerics/hmatrix/issues/307
packages.hmatrix.flags.no-random_r = true;
# Use pkg-config instead of pg_config to avoid:
# $ nix -L build .#legacyPackages.x86_64-linux.project.projectVariants.static.projectCross.musl64.hsPkgs.postgresql-libpq.components.library
# > Error: Setup: The program 'pg_config' is required but it could not be found
packages.postgresql-libpq.flags.use-pkg-config = true;
}
];
};
}; };
};
flake.crossPlatforms = platforms: flake.crossPlatforms = platforms:
pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ( pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 (
# For building static executables. # For building static executables.
pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
platforms.musl64 platforms.musl64
] ]
# For cross compiling to Windows. # For cross compiling to Windows.
# ++ [ platforms.mingwW64 ] # ++ [ platforms.mingwW64 ]
); );
# Shell configuration shared by the default shell # Shell configuration shared by the default shell
# and all shells from the flake.variants. # and all shells from the flake.variants.
shell = { shell = {
# Force cabal-install (by setting CABAL_CONFIG=) # Force cabal-install (by setting CABAL_CONFIG=)
# to use the packages selected by project.plan-nix. # to use the packages selected by project.plan-nix.
exactDeps = true; exactDeps = true;
# Provision (in `ghc-pkg list`) the **dependencies** of the packages selected here, # Provision (in `ghc-pkg list`) the **dependencies** of the packages selected here,
# which are not also selected here. # which are not also selected here.
# By default haskell.nix selects here all _local_ packages # By default haskell.nix selects here all _local_ packages
# (packages from both the packages and the source-repository-package stanzas) # (packages from both the packages and the source-repository-package stanzas)
# which therefore excludes source-repository-packages from being provisioned. # which therefore excludes source-repository-packages from being provisioned.
# Hence select only the _project_ packages (packages from the packages stanza). # Hence select only the _project_ packages (packages from the packages stanza).
packages = ps: lib.attrValues (haskellLib.selectProjectPackages ps); packages = ps: lib.attrValues (haskellLib.selectProjectPackages ps);
# Add in this list any development tool needed # Add in this list any development tool needed
# that is not expected to come from the developers' own system. # that is not expected to come from the developers' own system.
nativeBuildInputs = [ nativeBuildInputs = [
# Wraps cabal-install to remove source-repository-package stanzas, # Wraps cabal-install to remove source-repository-package stanzas,
# otherwise it would download an use them, # otherwise it would download an use them,
# likely because it does not know that those packages provisioned # likely because it does not know that those packages provisioned
# in `ghc-pkg list` must be used in priority. # in `ghc-pkg list` must be used in priority.
(let cabal-install = project.tool "cabal" { (
version = "latest"; let
#inherit index-state; cabal-install = project.tool "cabal" {
modules = [ version = "latest";
{ #inherit index-state;
# Preserve Bash completion for cabal. modules = [
packages.cabal-install.components.exes.cabal.postInstall = '' {
mkdir -p $out/share/bash-completion # Preserve Bash completion for cabal.
mv bash-completion $out/share/bash-completion/completions packages.cabal-install.components.exes.cabal.postInstall = ''
''; mkdir -p $out/share/bash-completion
} mv bash-completion $out/share/bash-completion/completions
]; '';
}; }
];
};
in in
# symlinkJoin cabal-install to preserve share/bash-completion/ # symlinkJoin cabal-install to preserve share/bash-completion/
pkgs.symlinkJoin { pkgs.symlinkJoin {
...@@ -361,109 +372,112 @@ ...@@ -361,109 +372,112 @@
"$out"/bin/cabal \ "$out"/bin/cabal \
--add-flags --project-file=cabal.project.flake --add-flags --project-file=cabal.project.flake
''; '';
}) }
)
# Provide HLS because it is tighly coupled to the GHC version in use. # Provide HLS because it is tighly coupled to the GHC version in use.
# TODO: uncomment when in public binary caches. # TODO: uncomment when in public binary caches.
#(project.tool "haskell-language-server" { version = "latest"; }) #(project.tool "haskell-language-server" { version = "latest"; })
(project.tool "ghcid" { version = "latest"; }) (project.tool "ghcid" { version = "latest"; })
(project.tool "hlint" { version = "latest"; }) (project.tool "hlint" { version = "latest"; })
]; ];
# cabal.project.flake must be in the same directory than the original cabal.project # cabal.project.flake must be in the same directory than the original cabal.project
# for the relative paths in the packages stanza to point to the correct subdirs. # for the relative paths in the packages stanza to point to the correct subdirs.
shellHook = '' shellHook = ''
ln -sf ${pkgs.runCommandLocal "cabal.project" { ln -sf ${pkgs.runCommandLocal "cabal.project" {
nativeBuildInputs = with pkgs; [ gawk ]; nativeBuildInputs = with pkgs; [ gawk ];
} }
# Strips source-repository-package stanzas from cabal.project. # Strips source-repository-package stanzas from cabal.project.
'' ''
awk '/^[^ ]/{f=/^source-repository-package/} !f' >$out ${./cabal.project} awk '/^[^ ]/{f=/^source-repository-package/} !f' >$out ${./cabal.project}
'' ''
} cabal.project.flake } cabal.project.flake
''; '';
# If true, builds a Hoogle documentation index of all dependencies, # If true, builds a Hoogle documentation index of all dependencies,
# and provides a "hoogle" command to search the index. # and provides a "hoogle" command to search the index.
withHoogle = false; withHoogle = false;
};
}; };
};
projectFlake = project.flake { };
in { projectFlake = project.flake { };
legacyPackages = pkgs // { in
# For exploring the project: {
# $ nix --extra-experimental-features 'flakes repl-flake' repl . legacyPackages = pkgs // {
# nix-repl> :lf . # For exploring the project:
# nix-repl> __attrNames legacyPackages.x86_64-linux.project # $ nix --extra-experimental-features 'flakes repl-flake' repl .
# [ "__overlay__" "appendModule" "appendOverlays" "args" "buildProject" "extend" # nix-repl> :lf .
# "flake" "flake'" "getComponent" "getPackage" "ghcWithHoogle" "ghcWithPackages" # nix-repl> __attrNames legacyPackages.x86_64-linux.project
# "hsPkgs" "index-state-max" "makeConfigFiles" "options" "pkg-set" "pkgs" # [ "__overlay__" "appendModule" "appendOverlays" "args" "buildProject" "extend"
# "plan-nix" "projectCoverageReport" "projectCross" "projectFunction" # "flake" "flake'" "getComponent" "getPackage" "ghcWithHoogle" "ghcWithPackages"
# "projectModule" "projectVariants" "roots" "shell" "shellFor" "tool" "tools" # "hsPkgs" "index-state-max" "makeConfigFiles" "options" "pkg-set" "pkgs"
# ] # "plan-nix" "projectCoverageReport" "projectCross" "projectFunction"
project = project; # "projectModule" "projectVariants" "roots" "shell" "shellFor" "tool" "tools"
# ]
project = project;
};
# For building a component of this project:
# $ nix -L build .#gargantext:exe:gargantext-phylo-profile
packages = projectFlake.packages;
# For entering the default development shell:
# $ nix -L develop
# $ cabal build --disable-optimization
#
# For entering the development shell variant "profiled":
# $ nix -L develop .#profiled
# $ cabal run gargantext-phylo-profile
devShells = projectFlake.devShells;
apps = projectFlake.apps // {
# For updating nix/cache/plan
# $ nix run .#update-nix-cache-plan
# $ git commit -m "nix: update nix/cache/plan"
update-nix-cache-plan = {
type = "app";
program = (pkgs.writeShellScript "update-nix-cache-plan" ''
set -x
${project.plan-nix.passthru.generateMaterialized} nix/cache/plan
git add --all nix/cache/plan
'').outPath;
}; };
# Register the project's toolchain for compiler-nix-name
# For building a component of this project: # (but not the Haskell package dependencies of the project)
# $ nix -L build .#gargantext:exe:gargantext-phylo-profile # to prevent nix-collect-garbage from removing them from the Nix store.
packages = projectFlake.packages; register-roots = {
type = "app";
# For entering the default development shell: program = (pkgs.writeShellScript "register-roots" ''
# $ nix -L develop nix-store --add-root nix/cache/roots --indirect --realise ${project.roots}
# $ cabal build --disable-optimization '').outPath;
#
# For entering the development shell variant "profiled":
# $ nix -L develop .#profiled
# $ cabal run gargantext-phylo-profile
devShells = projectFlake.devShells;
apps = projectFlake.apps // {
# For updating nix/cache/plan
# $ nix run .#update-nix-cache-plan
# $ git commit -m "nix: update nix/cache/plan"
update-nix-cache-plan = {
type = "app";
program = (pkgs.writeShellScript "update-nix-cache-plan" ''
set -x
${project.plan-nix.passthru.generateMaterialized} nix/cache/plan
git add --all nix/cache/plan
'').outPath;
};
# Register the project's toolchain for compiler-nix-name
# (but not the Haskell package dependencies of the project)
# to prevent nix-collect-garbage from removing them from the Nix store.
register-roots = {
type = "app";
program = (pkgs.writeShellScript "register-roots" ''
nix-store --add-root nix/cache/roots --indirect --realise ${project.roots}
'').outPath;
};
}; };
};
# For running all checks (very slow):
# $ nix -L flake check # For running all checks (very slow):
# FIXME: actually run them all and disable or fix the broken ones. # $ nix -L flake check
# # FIXME: actually run them all and disable or fix the broken ones.
# For running a specific check: #
# $ nix -L build .#checks.x86_64-linux.duckling:test:duckling-test # For running a specific check:
# bat result/test-stdout # $ nix -L build .#checks.x86_64-linux.duckling:test:duckling-test
# See names from: # bat result/test-stdout
# $ nix -L flake show --allow-import-from-derivation # See names from:
checks = projectFlake.checks // ( # $ nix -L flake show --allow-import-from-derivation
# Ignore projectFlake.checks which only contain checks = projectFlake.checks // (
# this project test-suites (and flake.variants) # Ignore projectFlake.checks which only contain
# and generate instead a check for each test-suite # this project test-suites (and flake.variants)
# of each package in the closure of this project. # and generate instead a check for each test-suite
let # of each package in the closure of this project.
projectClosure = project.appendModule { let
# haskell.nix's applyComponents filters-out non-planned components. projectClosure = project.appendModule {
# Hence enable planned for all components of the project's Haskell closure. # haskell.nix's applyComponents filters-out non-planned components.
modules = [ { planned = true; } ]; # Hence enable planned for all components of the project's Haskell closure.
}; modules = [{ planned = true; }];
testPackages = lib.mapAttrs (name: package: };
testPackages = lib.mapAttrs
(name: package:
let let
# Packages for which a plan cannot be computed # Packages for which a plan cannot be computed
# even with jailbreaking .cabal's constraints. # even with jailbreaking .cabal's constraints.
...@@ -512,76 +526,81 @@ ...@@ -512,76 +526,81 @@
}; };
in in
if package != null if package != null
&& (package.isHaskell or false) && (package.isHaskell or false)
# Already provided by projectFlake.checks # Already provided by projectFlake.checks
&& !(package.isProject or false) && !(package.isProject or false)
# Some packages cannot be used: # Some packages cannot be used:
# error: The option `packages.BNFC.package.identifier.name' is used but not defined. # error: The option `packages.BNFC.package.identifier.name' is used but not defined.
&& (package.components ? "library") && (package.components ? "library")
# Some packages cannot be used: # Some packages cannot be used:
# error: The option `packages.GLFW-b.package.identifier.name' is used but not defined. # error: The option `packages.GLFW-b.package.identifier.name' is used but not defined.
&& builtins.length (builtins.attrNames package.components.tests) != 0 && builtins.length (builtins.attrNames package.components.tests) != 0
&& !(lib.elem name brokenPackages) && !(lib.elem name brokenPackages)
then then
# This includes this project's packages # This includes this project's packages
# and source-repository-package. # and source-repository-package.
if projectClosure.hsPkgs.${name}.isLocal if projectClosure.hsPkgs.${name}.isLocal
then projectClosure.hsPkgs.${name} then projectClosure.hsPkgs.${name}
else pkgs.haskell-nix.hackage-package { else
name = package.identifier.name; pkgs.haskell-nix.hackage-package {
version = package.identifier.version; name = package.identifier.name;
revision = package.identifier.revision or "default"; version = package.identifier.version;
compiler-nix-name = compiler-nix-name; revision = package.identifier.revision or "default";
inherit index-state; compiler-nix-name = compiler-nix-name;
# Unfortunately I cannot find a shorter way inherit index-state;
# to use jailbreak-cabal since haskell.nix # Unfortunately I cannot find a shorter way
# only applies postPatch in builder/comp-builder.nix # to use jailbreak-cabal since haskell.nix
# thus when building a component and not before building a plan. # only applies postPatch in builder/comp-builder.nix
# Hence copy and adapt modules/hackage-project.nix's src # thus when building a component and not before building a plan.
src = lib.mkIf (lib.elem name jailbreakPackages) ( # Hence copy and adapt modules/hackage-project.nix's src
let src = lib.mkIf (lib.elem name jailbreakPackages) (
revision = package.identifier.revision or "default"; let
version = package.identifier.version; revision = package.identifier.revision or "default";
tarball = pkgs.fetchurl { version = package.identifier.version;
url = "mirror://hackage/${name}-${version}.tar.gz"; tarball = pkgs.fetchurl {
inherit (pkgs.haskell-nix.hackage.${name}.${version}) sha256; url = "mirror://hackage/${name}-${version}.tar.gz";
}; inherit (pkgs.haskell-nix.hackage.${name}.${version}) sha256;
rev = pkgs.haskell-nix.hackage.${name}.${version}.revisions.${revision}; };
cabalFile = pkgs.fetchurl { rev = pkgs.haskell-nix.hackage.${name}.${version}.revisions.${revision};
url = "https://hackage.haskell.org/package/${name}-${version}/revision/${toString rev.revNum}.cabal"; cabalFile = pkgs.fetchurl {
inherit (rev) sha256; url = "https://hackage.haskell.org/package/${name}-${version}/revision/${toString rev.revNum}.cabal";
}; inherit (rev) sha256;
revSuffix = lib.optionalString (rev.revNum > 0) "-r${toString rev.revNum}"; };
in lib.mkOverride 1000 (pkgs.runCommand "${name}-${version}${revSuffix}-src" { revSuffix = lib.optionalString (rev.revNum > 0) "-r${toString rev.revNum}";
# Avoid readDir and readFile IFD functions looking for these project files in the hackage source in
passthru.lookForCabalProject = false; lib.mkOverride 1000 (pkgs.runCommand "${name}-${version}${revSuffix}-src"
} ('' {
tmp=$(mktemp -d) # Avoid readDir and readFile IFD functions looking for these project files in the hackage source
cd $tmp passthru.lookForCabalProject = false;
tar xzf ${tarball} }
mv "${name}-${version}" $out (''
'' + lib.optionalString (rev.revNum > 0) '' tmp=$(mktemp -d)
cp ${cabalFile} $out/${name}.cabal cd $tmp
'' + '' tar xzf ${tarball}
${jailbreak-cabal.components.exes.jailbreak-cabal.exePath} $out/${name}.cabal mv "${name}-${version}" $out
'') // { '' + lib.optionalString (rev.revNum > 0) ''
# TODO remove once nix >=2.4 is widely adopted (will trigger rebuilds of everything). cp ${cabalFile} $out/${name}.cabal
# Disable filtering keeps pre ond post nix 2.4 behaviour the same. This means that '' + ''
# the same `alex`, `happy` and `hscolour` are used to build GHC. It also means that ${jailbreak-cabal.components.exes.jailbreak-cabal.exePath} $out/${name}.cabal
# that `tools` in the shell will be built the same. '') // {
filterPath = { path, ... }: path; # TODO remove once nix >=2.4 is widely adopted (will trigger rebuilds of everything).
}) # Disable filtering keeps pre ond post nix 2.4 behaviour the same. This means that
); # the same `alex`, `happy` and `hscolour` are used to build GHC. It also means that
} # that `tools` in the shell will be built the same.
filterPath = { path, ... }: path;
})
);
}
else null else null
) projectClosure.hsPkgs; )
in projectClosure.hsPkgs;
haskellLib.mkFlakeChecks (haskellLib.collectChecks' testPackages) in
); haskellLib.mkFlakeChecks (haskellLib.collectChecks' testPackages)
);
#hydraJobs = projectFlake.hydraJobs;
} #hydraJobs = projectFlake.hydraJobs;
); }
);
# Ask users to set Nix config entries in its local nix.conf. # Ask users to set Nix config entries in its local nix.conf.
nixConfig = { nixConfig = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment