on 19052d8 help sign in
haskell.nix/modules/component-driver.nix
97 lines 3.6 kB history raw
1{ config, pkgs, lib, haskellLib, buildModules, ... }:
2let
3 builder = haskellLib.weakCallPackage pkgs ../builder {
4 inherit haskellLib;
5 ghc = config.ghc.package;
6 compiler-nix-name = config.compiler.nix-name;
7 inherit (config) nonReinstallablePkgs hsPkgs compiler;
8 };
10in
13 # This has a slightly modified option type. We will *overwrite* any previous
14 # setting of nonRelocatablePkgs, instead of merging them. Otherwise you
15 # have no chance of removing packages retroactively. We might improve this
16 # by implementing a logic that would allow +xxx to be added, -xxx to be removed
17 # and if it's not a list of -/+ prefixed strings, be assumed to be overwriting.
18 # This seems ugly.
19 options.nonReinstallablePkgs = lib.mkOption {
20 type = (lib.types.listOf lib.types.str) // {
21 merge = loc: defs: lib.last (lib.getValues defs);
22 };
23 };
25 options.reinstallableLibGhc = lib.mkOption {
26 type = lib.types.bool;
27 default = false;
28 description = "Is lib:ghc reinstallable?";
29 };
30 options.setup-depends = lib.mkOption {
31 type = lib.types.listOf lib.types.unspecified;
32 default = [];
33 description = "pkgs to globally provide to Setup.hs builds";
34 };
36 # Dependencies (with reinstallable-lib:ghc)
37 #
38 # .--------. .------------------.
39 # | pretty | < ------- | template-haskell |
40 # '--------' '------------------'
41 # v |
42 # .---------. .-------. |
43 # | deepseq | - > | array | |
44 # '---------' '-------' v
45 # v v .-------------.
46 # .----------. .----------. .------. .- | ghc-boot-th |
47 # | ghc-heap | | ghc-prim | | base |< -' '-------------'
48 # '----------' '----------' '------' .----------------.
49 # | v | | | integer-simple |
50 # | .-----. | '-- > |-------or-------|
51 # '---- > | rts | < -----' | integer-gmp |
52 # '-----' '----------------'
53 #
54 # without reinstallable-lib:ghc, this is significantly larger.
56 config.nonReinstallablePkgs =
57 [ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
58 "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
59 # ghcjs custom packages
60 "ghcjs-prim" "ghcjs-th"
61 ]
62 # TODO make this unconditional
63 ++ lib.optionals (config.compiler.nix-name == "ghc901") [
64 "ghc-bignum" ]
65 ++ lib.optionals (!config.reinstallableLibGhc) [
66 "ghc-boot"
67 "ghc" "Cabal" "Win32" "array" "binary" "bytestring" "containers"
68 "directory" "filepath" "ghc-boot" "ghc-compact" "ghc-prim"
69 # "ghci" "haskeline"
70 "hpc"
71 "mtl" "parsec" "process" "text" "time" "transformers"
72 "unix" "xhtml" "terminfo"
73 # "stm"
74 ];
76 options.bootPkgs = lib.mkOption {
77 type = lib.types.listOf lib.types.str;
78 };
80 config.bootPkgs = [
81 "rts" "ghc-boot-th"
82 "ghc-heap" # since ghc 8.6.
83 "ghcjs-prim"
84 ] ++ lib.optional (!config.reinstallableLibGhc) "ghc";
86 options.hsPkgs = lib.mkOption {
87 type = lib.types.unspecified;
88 };
90 config.hsPkgs =
91 { inherit (builder) shellFor makeConfigFiles ghcWithPackages ghcWithHoogle;
92 buildPackages = buildModules.config.hsPkgs;
93 } //
94 lib.mapAttrs
95 (name: pkg: if pkg == null then null else builder.build-package config pkg)
96 (config.packages // lib.genAttrs (config.nonReinstallablePkgs ++ config.bootPkgs) (_: null));