on 4e100b2 help sign in
haskell.nix/modules/component-driver.nix
103 lines 3.8 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 = true;
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-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 (
64 __elem config.compiler.nix-name ["ghc901" "ghc902" "ghc921" "ghc922" "ghc923"]) [
65 "ghc-bignum" ]
66 ++ lib.optionals (!config.reinstallableLibGhc) [
67 "ghc-boot"
68 "ghc" "Cabal" "Win32" "array" "binary" "bytestring" "containers"
69 "directory" "filepath" "ghc-boot" "ghc-compact" "ghc-prim"
70 # "ghci" "haskeline"
71 "hpc"
72 "mtl" "parsec" "process" "text" "time" "transformers"
73 "unix" "xhtml" "terminfo"
74 # "stm"
75 ]
76 ++ lib.optionals (!config.reinstallableLibGhc || __elem config.compiler.nix-name ["ghc865"]) [
77 "ghc-heap"
78 ];
80 options.bootPkgs = lib.mkOption {
81 type = lib.types.listOf lib.types.str;
82 };
84 config.bootPkgs = [
85 "rts" "ghc-boot-th"
86 "ghcjs-prim"
87 ] ++ lib.optional (!config.reinstallableLibGhc) "ghc"
88 ++ lib.optionals (
89 __elem config.compiler.nix-name ["ghc901" "ghc902" "ghc921" "ghc922" "ghc923"]) [
90 "ghc-bignum" ];
92 options.hsPkgs = lib.mkOption {
93 type = lib.types.unspecified;
94 };
96 config.hsPkgs =
97 { inherit (builder) shellFor makeConfigFiles ghcWithPackages ghcWithHoogle;
98 buildPackages = buildModules.config.hsPkgs;
99 } //
100 lib.mapAttrs
101 (name: pkg: if pkg == null then null else builder.build-package config pkg)
102 (config.packages // lib.genAttrs (config.nonReinstallablePkgs ++ config.bootPkgs) (_: null));