on iko/ghcjs-patch-master help sign in
Option for exact-config
commit1bb2a42d3ab8b3b0933040463b7b36a7a096ee5a authorWill Fancher <elvishjerricco@gmail.com> dateThu 1 Nov 2018, 06:12 (8 years ago) parenta48f33f
4 files changed+35−10
builder/comp-builder.nix+18−3 builder/default.nix+2−2 modules/component-driver.nix+11−5 modules/package.nix+4
builder/comp-builder.nix+18−3
@@ -1,4 +1,4 @@
1−{ stdenv, ghc, lib, pkgconfig, writeText, runCommand, haskellLib }:
1+{ stdenv, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs }:
22
33{ componentId
44, component
@@ -27,7 +27,14 @@ let
2727 };
2828 in map ({val,...}: val) closure;
2929
30− configFiles = runCommand "${fullName}-config" { nativeBuildInputs = [ghc]; } ''
30+ exactDep = pdbArg: p: ''
31+ if id=$(ghc-pkg ${pdbArg} field ${p} id --simple-output); then
32+ echo "--dependency=${p}=$id" >> $out/configure-flags
33+ # TODO: Figure out how to do this for cabal.config for nix-shell
34+ fi
35+ '';
36+
37+ configFiles = runCommand "${fullName}-config" { nativeBuildInputs = [ghc]; } (''
3138 mkdir -p $out
3239 ghc-pkg init $out/package.conf.d
3340
@@ -44,8 +51,16 @@ let
4451
4552 echo ${lib.concatStringsSep " " (lib.mapAttrsToList (fname: val: "--flags=${lib.optionalString (!val) "-" + fname}") flags)} >> $out/configure-flags
4653
54+ '' + lib.optionalString component.doExactConfig ''
55+ echo "--exact-configuration" >> $out/configure-flags
56+ echo "exact-configuration: True" >> $out/cabal.config
57+
58+ ${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library}/package.conf.d" p.identifier.name) component.depends}
59+ ${lib.concatMapStringsSep "\n" (exactDep "") nonReinstallablePkgs}
60+
61+ '' + ''
4762 ghc-pkg --package-db $out/package.conf.d check
48− '';
63+ '');
4964
5065 finalConfigureFlags = lib.concatStringsSep " " (
5166 [ "--prefix=$out" "${componentId.ctype}:${componentId.cname}" ]
builder/default.nix+2−2
@@ -1,4 +1,4 @@
1−{ pkgs, stdenv, lib, haskellLib, ghc, fetchurl, writeText, runCommand, pkgconfig }:
1+{ pkgs, stdenv, lib, haskellLib, ghc, fetchurl, writeText, runCommand, pkgconfig, nonReinstallablePkgs }:
22
33{ flags
44, package
@@ -53,7 +53,7 @@ let
5353 '';
5454 };
5555
56− comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib; };
56+ comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs; };
5757
5858 buildComp = componentId: component: comp-builder {
5959 inherit componentId component package name src flags setup cabalFile;
modules/component-driver.nix+11−5
@@ -4,19 +4,25 @@ let
44 new-builder = haskellLib.weakCallPackage pkgs ../builder {
55 inherit haskellLib;
66 ghc = config.ghc.package;
7+ inherit (config) nonReinstallablePkgs;
78 };
8−
9− nonReinstallablePkgs = [ "rts" "ghc" "ghc-prim" "integer-gmp" "integer-simple" "base"
10− "array" "deepseq" "pretty" "ghc-boot-th" "template-haskell"];
119in
1210
1311{
12+ options.nonReinstallablePkgs = lib.mkOption {
13+ type = lib.types.listOf lib.types.str;
14+ };
15+
16+ config.nonReinstallablePkgs =
17+ [ "rts" "ghc" "ghc-prim" "integer-gmp" "integer-simple" "base"
18+ "array" "deepseq" "pretty" "ghc-boot-th" "template-haskell" ];
19+
1420 options.hsPkgs = lib.mkOption {
1521 type = lib.types.unspecified;
1622 };
1723
1824 config.hsPkgs = { buildPackages = config.hsPkgs; }
1925 // lib.mapAttrs
20− (name: pkg: if pkg == null || builtins.elem name nonReinstallablePkgs then null else new-builder pkg)
21− config.packages;
26+ (name: pkg: if pkg == null then null else new-builder pkg)
27+ (config.packages // lib.genAttrs config.nonReinstallablePkgs (_: null));
2228}
modules/package.nix+4
@@ -123,6 +123,10 @@ in {
123123 type = listOfFilteringNulls str;
124124 default = [];
125125 };
126+ doExactConfig = mkOption {
127+ type = bool;
128+ default = false;
129+ };
126130 };
127131 };
128132 in {