1# package descriptions in hackage will look like:
2# { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs }:
3# { flags = { flag1 = false; flags2 = true; ... };
4# package = { specVersion = "X.Y"; identifier = { name = "..."; version = "a.b.c.d"; };
5# license = "..."; copyright = "..."; maintainer = "..."; author = "...";
6# homepage = "..."; url = "..."; synopsis = "..."; description = "...";
7# buildType = "Simple"; # or Custom, Autoconf, ...
10# "..." = { depends = [ (hsPkgs.base) ... ]; };
11# exes = { "..." = { depends = ... };
12# "..." = { depends = ... }; };
13# tests = { "..." = { depends = ... }; ... };
16{ parentConfig, mod_args, listOfFilteringNulls, componentOptions, packageOptions }:
17{ lib, config, pkgs, haskellLib, ... }:
22# Work around issue that can cause _lots_ of files to be copied into the store.
23# See https://github.com/NixOS/nixpkgs/pull/64691
25 path = types.path // { check = x: types.path.check (x.origSrc or x); };
27 componentType = submodule {
28 # add the shared componentOptions
29 options = (packageOptions config) // {
30 buildable = mkOption {
35 type = listOfFilteringNulls unspecified;
39 type = listOfFilteringNulls (nullOr package);
42 frameworks = mkOption {
43 type = listOfFilteringNulls package;
46 pkgconfig = mkOption {
47 type = listOf (listOfFilteringNulls package);
50 build-tools = mkOption {
51 type = listOfFilteringNulls unspecified;
55 type = listOfFilteringNulls unspecified;
58 asmSources = mkOption {
59 type = listOfFilteringNulls unspecified;
62 cmmSources = mkOption {
63 type = listOfFilteringNulls unspecified;
67 type = listOfFilteringNulls unspecified;
70 cxxSources = mkOption {
71 type = listOfFilteringNulls unspecified;
74 jsSources = mkOption {
75 type = listOfFilteringNulls unspecified;
78 hsSourceDirs = mkOption {
79 type = listOfFilteringNulls unspecified;
82 includeDirs = mkOption {
83 type = listOfFilteringNulls unspecified;
87 type = listOfFilteringNulls unspecified;
91 type = listOfFilteringNulls unspecified;
94 extraSrcFiles = mkOption {
95 type = listOfFilteringNulls unspecified;
98 platforms = mkOption {
99 type = nullOr (listOfFilteringNulls unspecified);
106 # This is how the Nix expressions generated by *-to-nix receive
107 # their flags argument.
108 config._module.args = mod_args // { flags = config.flags; };
110 options = (packageOptions parentConfig) // {
111 # TODO: Add descriptions to everything.
116 specVersion = mkOption {
120 identifier.name = mkOption {
124 identifier.version = mkOption {
132 copyright = mkOption {
136 maintainer = mkOption {
144 homepage = mkOption {
152 synopsis = mkOption {
156 description = mkOption {
160 buildType = mkOption {
164 setup-depends = mkOption {
165 type = listOfFilteringNulls unspecified;
169 detailLevel = mkOption {
171 default = "MinimalDetails";
174 licenseFiles = mkOption {
175 type = listOfFilteringNulls unspecified;
184 dataFiles = mkOption {
185 type = listOfFilteringNulls unspecified;
189 extraSrcFiles = mkOption {
190 type = listOfFilteringNulls unspecified;
194 extraTmpFiles = mkOption {
195 type = listOfFilteringNulls unspecified;
199 extraDocFiles = mkOption {
200 type = listOfFilteringNulls unspecified;
204 cleanHpack = mkOption {
214 isProject = mkOption {
219 buildable = mkOption {
227 type = nullOr componentType;
232 doExactConfig = false;
233 # We have to set hsSourceDirs or cleanCabalComponent will
234 # include everything (and as a result all the components of
235 # the package will depend on everything in the package).
236 # TODO find a better way
237 hsSourceDirs = ["setup-src"];
244 extraSrcFiles = [ "Setup.hs" "Setup.lhs" ];
249 type = nullOr componentType;
253 type = attrsOf componentType;
256 foreignlibs = mkOption {
257 type = attrsOf componentType;
261 type = attrsOf componentType;
265 type = attrsOf componentType;
268 benchmarks = mkOption {
269 type = attrsOf componentType;
276 default = "${config.package.identifier.name}-${config.package.identifier.version}";
277 defaultText = "\${config.package.identifier.name}-\${config.package.identifier.version}";
284 type = either path package;
285 default = pkgs.fetchurl { url = "mirror://hackage/${config.name}.tar.gz"; inherit (config) sha256; };
286 defaultText = "pkgs.fetchurl { url = \"mirror://hackage/\${config.name}.tar.gz\"; inherit (config) sha256; };";
288 cabal-generator = mkOption {
292 revision = mkOption {
296 revisionSha256 = mkOption {
301 type = listOf (either unspecified path);
304 # This used to be `components.all` but it has been added back as `allComponent` to
305 # to avoid confusion. It is not mapped by `builder/hspkg-builder.nix` to anything
306 # you can build. Instead it is used internally when `configureAllComponents`
307 # is set or for tests whe on `cabal-doctest` is in the `setup-depends` of the package.
308 allComponent = mkOption {
309 type = componentType;
310 apply = all: all // {
311 # TODO: Should this check for the entire component
312 # definition to match, rather than just the identifier?
313 depends = builtins.filter (p: p.identifier != config.package.identifier) all.depends;
315 description = "The merged dependencies of all other components";
319 # This has one quirk. Manually setting options on the all component
320 # will be considered a conflict. This is almost always fine; most
321 # settings should be modified in either the package options, or an
322 # individual component's options. When this isn't sufficient,
323 # mkForce is a reasonable workaround.
325 # An alternative solution to mkForce for many of the options where
326 # this is relevant would be to switch from the bool type to
327 # something like an anyBool type, which would merge definitions by
328 # returning true if any is true.
329 config.allComponent =
330 let allComps = haskellLib.getAllComponents config;
333 # Exclude attributes that are likely to have conflicting definitions
334 # (a common use case for `all` is in `shellFor` and it only has an
336 builtins.removeAttrs c ["preCheck" "postCheck" "keepSource"]
339 # If any one of the components needs us to keep the source
340 # then keep it for the `all` component
341 keepSource = lib.foldl' (x: comp: x || comp.keepSource) false allComps;
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