on 19052d8 help sign in
haskell.nix/modules/cabal-project.nix
133 lines 4.4 kB history raw
1{ lib, config, pkgs, haskellLib, ... }:
2with lib;
3with types;
4let readIfExists = src: fileName:
5 let origSrcDir = src.origSrcSubDir or src;
6 in
7 if builtins.elem ((__readDir origSrcDir)."${fileName}" or "") ["regular" "symlink"]
8 then __readFile (origSrcDir + "/${fileName}")
9 else null;
10in {
11 _file = "haskell.nix/modules/cabal-project.nix";
12 options = {
13 # Used by callCabalProjectToNix
14 compiler-nix-name = mkOption {
15 type = str;
16 description = "The name of the ghc compiler to use eg. \"ghc884\"";
17 };
18 index-state = mkOption {
19 type = nullOr str;
20 default = null;
21 description = "Hackage index-state, eg. \"2019-10-10T00:00:00Z\"";
22 };
23 index-sha256 = mkOption {
24 type = nullOr str;
25 default = null;
26 description = "The hash of the truncated hackage index-state";
27 };
28 plan-sha256 = mkOption {
29 type = nullOr str;
30 default = null;
31 description = "The hash of the plan-to-nix output (makes the plan-to-nix step a fixed output derivation)";
32 };
33 materialized = mkOption {
34 type = nullOr (either path package);
35 default = null;
36 description = "Location of a materialized copy of the nix files";
37 };
38 checkMaterialization = mkOption {
39 type = nullOr bool;
40 default = null;
41 description = "If true the nix files will be generated used to check plan-sha256 and material";
42 };
43 cabalProjectFileName = mkOption {
44 type = str;
45 default = "cabal.project";
46 };
47 cabalProject = mkOption {
48 type = nullOr str;
49 default = readIfExists config.src config.cabalProjectFileName;
50 };
51 cabalProjectLocal = mkOption {
52 type = nullOr str;
53 default = readIfExists config.src "${config.cabalProjectFileName}.local";
54 };
55 cabalProjectFreeze = mkOption {
56 type = nullOr str;
57 default = readIfExists config.src "${config.cabalProjectFileName}.freeze";
58 };
59 caller = mkOption {
60 type = str;
61 default = "callCabalProjectToNix";
62 description = "Name of the calling function for better warning messages";
63 };
64 ghc = mkOption {
65 type = nullOr package;
66 default = null;
67 description = "Deprecated in favour of `compiler-nix-name`";
68 };
69 ghcOverride = mkOption {
70 type = nullOr package;
71 default = null;
72 description = "Used when we need to set ghc explicitly during bootstrapping";
73 };
74 # The defaults for `nix-tools` and `cabal-install` are in `call-cabal-project-to-nix.nix`
75 # to make sure it is not evaluated too strictly (which would lead to infinite recursion).
76 nix-tools = mkOption {
77 type = nullOr package;
78 default = null;
79 description = "nix-tools to use when converting the `plan.json` to nix";
80 };
81 cabal-install = mkOption {
82 type = nullOr package;
83 default = null;
84 description = "cabal-install to use when running `cabal configure`";
85 };
86 configureArgs = mkOption {
87 type = nullOr str;
88 default = "";
89 description = ''
90 Extra arguments to pass to `cabal v2-configure`.
91 `--enable-tests --enable-benchmarks` are included by default.
92 If the tests and benchmarks are not needed and they
93 cause the wrong plan to be chosen, then we can use
94 `configureArgs = "--disable-tests --disable-benchmarks";`
95 '';
96 };
97 sha256map = mkOption {
98 type = nullOr unspecified;
99 default = null;
100 description = ''
101 An alternative to adding `--sha256` comments into the
102 cabal.project file:
103 sha256map =
104 { "https://github.com/jgm/pandoc-citeproc"."0.17"
105 = "0dxx8cp2xndpw3jwiawch2dkrkp15mil7pyx7dvd810pwc22pm2q"; };
106 '';
107 };
108 lookupSha256 = mkOption {
109 type = nullOr unspecified;
110 default = if config.sha256map != null
111 then { location, tag, ...}: config.sha256map.${location}.${tag}
112 else _: null;
113 };
114 extra-hackage-tarballs = mkOption {
115 type = nullOr (listOf unspecified);
116 default = [];
117 };
119 # Used by mkCabalProjectPkgSet
120 pkg-def-extras = mkOption {
121 type = nullOr (listOf unspecified);
122 default = [];
123 };
124 modules = mkOption {
125 type = nullOr (listOf unspecified);
126 default = [];
127 };
128 extra-hackages = mkOption {
129 type = nullOr (listOf unspecified);
130 default = [];
131 };
132 };