1# The plan (that is, a package set description like an LTS set or a
2# plan.nix (derived from plan.json)) will producde a structure that
3# looks like, which is stored in config.plan.pkg-def:
5# { packages = { "package" = { revision = hackageConfigs.$package.$version.revisions.default;
6# flags = { flag1 = true; flag2 = false; ... }; };
8# compiler = { version = "X.Y.Z"; nix-name ="ghcXYZ";
9# # packages that come bundled with the compiler
10# packages = { "bytestring" = "a.b.c.d"; ... }; };
13{ lib, config, pkgs, pkgconfPkgs, haskellLib, ... }:
19 # dealing with str is a bit annoying espectially with `nullOr str` as that apparently defaults to ""
20 # instead of null :shrug:. This then messes with our option inheritance logic.
21 # Hence we have a uniqueStr type that ensures multiple identially defined options are collapsed
22 # without raising an error. And a way to fetch default options that will retain `null` if the
23 # option is not defined or "".
24 getDefaultOrNull = def: key: if def ? ${key} && def.${key} != "" then def.${key} else null;
25 mergeUniqueOption = locs: defs: let
26 mergeOneOption = loc: defs':
27 # we ignore "" as optionalString, will default to "".
28 let defs = filter (x: x.value != "") defs'; in
29 if defs == [] then null
30 else if length defs != 1 then
31 throw "The unique option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}; with values `${concatStringsSep "', `" (map (x: x.value) defs)}'."
32 else (head defs).value;
33 in mergeOneOption locs (lists.unique defs);
34 uniqueStr = str // { merge = mergeUniqueOption; };
36 # This is just like listOf, except that it filters out all null elements.
37 listOfFilteringNulls = elemType: listOf elemType // {
38 # Mostly copied from nixpkgs/lib/types.nix
40 map (x: x.value) (filter (x: x ? value && x.value != null) (concatLists (imap1 (n: def:
41 if isList def.value then
44 (loc ++ ["[definition ${toString n}-entry ${toString m}]"])
46 [{ inherit (def) file; value = def'; }]
50 throw "The option value `${showOption loc}` in `${def.file}` is not a list.") defs)));
53 componentOptions = def: {
54 buildable = mkOption {
58 configureFlags = mkOption {
59 type = listOfFilteringNulls str;
60 default = (def.configureFlags or []);
62 setupBuildFlags = mkOption {
63 type = listOfFilteringNulls str;
64 default = (def.setupBuildFlags or []);
66 testFlags = mkOption {
67 type = listOfFilteringNulls str;
68 default = (def.testFlags or []);
70 setupInstallFlags = mkOption {
71 type = listOfFilteringNulls str;
72 default = (def.setupInstallFlags or []);
74 setupHaddockFlags = mkOption {
75 type = listOfFilteringNulls str;
76 default = (def.setupHaddockFlags or []);
78 doExactConfig = mkOption {
80 default = (def.doExactConfig or false);
84 default = (def.doCheck or true);
86 doCrossCheck = mkOption {
87 description = "Run doCheck also in cross compilation settings. This can be tricky as the test logic must know how to run the tests on the target.";
89 default = (def.doCrossCheck or false);
91 doHaddock = mkOption {
92 description = "Enable building of the Haddock documentation from the annotated Haskell source code.";
94 default = (def.doHaddock or true);
97 description = "Also build a hoogle index.";
99 default = (def.doHoogle or true);
101 doHyperlinkSource = mkOption {
102 description = "Link documentation to the source code.";
104 default = (def.doHyperlinkSource or true);
106 doQuickjump = mkOption {
107 description = "Generate an index for interactive documentation navigation.";
109 default = (def.doQuickjump or true);
111 dontPatchELF = mkOption {
112 description = "If set, the patchelf command is not used to remove unnecessary RPATH entries. Only applies to Linux.";
114 default = (def.dontPatchELF or true);
116 dontStrip = mkOption {
117 description = "If set, libraries and executables are not stripped.";
119 default = (def.dontStrip or true);
121 enableDeadCodeElimination = mkOption {
122 description = "If set, enables split sections for link-time dead-code stripping. Only applies to Linux";
124 default = (def.enableDeadCodeElimination or true);
126 enableStatic = mkOption {
127 description = "If set, enables building static libraries and executables.";
129 default = (def.enableStatic or true);
131 enableShared = mkOption {
132 description = "If set, enables building shared libraries.";
134 default = (def.enableShared or true);
136 shellHook = mkOption {
137 description = "Hook to run when entering a shell";
138 type = unspecified; # Can be either a string or a function
139 default = (def.shellHook or "");
141 enableLibraryProfiling = mkOption {
143 default = (def.enableLibraryProfiling or false);
146 enableSeparateDataOutput = mkOption {
148 default = (def.enableSeparateDataOutput or false);
151 enableExecutableProfiling = mkOption {
153 default = (def.enableExecutableProfiling or false);
156 profilingDetail = mkOption {
157 type = nullOr uniqueStr;
158 default = (def.profilingDetail or "default");
161 keepSource = mkOption {
163 default = (def.keepSource or false);
164 description = "Keep component source in the store in a `source` output";
167 packageOptions = def: componentOptions def // {
168 preUnpack = mkOption {
170 default = (def.preUnpack or null);
172 postUnpack = mkOption {
173 type = nullOr uniqueStr;
174 default = getDefaultOrNull def "postUnpack";
176 preConfigure = mkOption {
177 type = nullOr uniqueStr;
178 default = getDefaultOrNull def "preConfigure";
180 postConfigure = mkOption {
181 type = nullOr uniqueStr;
182 default = getDefaultOrNull def "postConfigure";
184 preBuild = mkOption {
185 type = nullOr uniqueStr;
186 default = getDefaultOrNull def "preBuild";
188 postBuild = mkOption {
189 type = nullOr uniqueStr;
190 default = getDefaultOrNull def "postBuild";
192 preCheck = mkOption {
193 type = nullOr uniqueStr;
194 default = getDefaultOrNull def "preCheck";
196 # Wrapper for test executable run in checkPhase
197 testWrapper = mkOption {
198 type = listOfFilteringNulls str;
199 default = def.testWrapper or [];
200 description = "A command to run for executing tests in checkPhase, which takes the original test command as its arguments.";
203 postCheck = mkOption {
204 type = nullOr uniqueStr;
205 default = getDefaultOrNull def "postCheck";
207 preInstall = mkOption {
208 type = nullOr uniqueStr;
209 default = getDefaultOrNull def "preInstall";
211 postInstall = mkOption {
212 type = nullOr uniqueStr;
213 default = getDefaultOrNull def "postInstall";
215 preHaddock = mkOption {
216 type = nullOr uniqueStr;
217 default = getDefaultOrNull def "preHaddock";
219 postHaddock = mkOption {
220 type = nullOr uniqueStr;
221 default = getDefaultOrNull def "postHaddock";
227 # Global options. These are passed down to the package level, and from there to the
228 # component level, unless specifically overridden. Depending on the flag flags are
229 # combined or replaced. We seed the package Options with an empty set forcing the
231 options = (packageOptions {}) // {
233 packages = mkOption {
236 inherit pkgs pkgconfPkgs haskellLib;
237 inherit (config) hsPkgs errorHandler;
238 inherit (config.cabal) system compiler;
240 attrsOf (submodule (import ./package.nix {
241 inherit mod_args listOfFilteringNulls;
242 inherit componentOptions packageOptions;
243 parentConfig = config;
251 nix-name = mkOption {
254 packages = mkOption {
259 plan.pkg-def = mkOption {
266 config = let module = config.plan.pkg-def config.hackage.configs; in {
267 inherit (module) compiler;
268 packages = lib.mapAttrs (name: { revision, ... }@revArgs: { system, compiler, flags, pkgs, hsPkgs, errorHandler, pkgconfPkgs, ... }@modArgs:
270 let m = if revision == null
271 then (abort "${name} has no revision!")
272 else revision (modArgs // { hsPkgs = hsPkgs // (mapAttrs (l: _: hsPkgs.${name}.components.sublibs.${l}) (m.components.sublibs or {})); });
274 m // { flags = lib.mapAttrs (_: lib.mkDefault) (m.flags // revArgs.flags or {}); }
275 ) (lib.filterAttrs (n: v: v == null || v.revision != null ) module.packages);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list