on iko/ghcjs-patch-master help sign in
Allow materialized only (#563)
e4d75d6Hamish Mackenzie
lib/materialize.nix+15−16
@@ -1,12 +1,14 @@
1{ pkgs, nix, runCommand, checkMaterialization }@defaults:
1{ pkgs, nix, runCommand, checkMaterialization }@defaults:
2−{ sha256
2+{ sha256 ? null # Has to make this a fixed output derivation
3+, sha256Arg ? "sha256"
3−, sha256Arg # Name of the sha256 argument for more meaningful
4+ # Name of the sha256 argument for more meaningful
4 # error messages when checking the materialization.
5 # error messages when checking the materialization.
5, materialized # null or path where to find materialized version of
6, materialized # null or path where to find materialized version of
6 # the output. If this is set but does not exist
7 # the output. If this is set but does not exist
7 # the derivation will fail but with a message
8 # the derivation will fail but with a message
8 # advising how to populate it.
9 # advising how to populate it.
10+, reasonNotSafe ? null
9−, reasonNotSafe # Some times there a reasont the derivation will
11+ # Some times there a reasont the derivation will
10 # not produce output that can be safely materialized.
12 # not produce output that can be safely materialized.
11 # Set this to a string explaining why and materialization
13 # Set this to a string explaining why and materialization
12 # will not be used (if sha256 was set an error will be
14 # will not be used (if sha256 was set an error will be
@@ -37,7 +39,7 @@ let
37 # Warn the user if they tried to pin stuff down when it is not safe
39 # Warn the user if they tried to pin stuff down when it is not safe
38 traceIgnoringSha256 reasonNotSafe
40 traceIgnoringSha256 reasonNotSafe
39 (traceIgnoringMaterialized reasonNotSafe calculateNoHash)
41 (traceIgnoringMaterialized reasonNotSafe calculateNoHash)
40− else if sha256 == null
42+ else if sha256 == null && materialized == null
41 then
43 then
42 # Let the user know how to calculate a sha256 to use to make this
44 # Let the user know how to calculate a sha256 to use to make this
43 # a fixed output derivation.
45 # a fixed output derivation.
@@ -52,7 +54,7 @@ let
52 calculateUseHash
54 calculateUseHash
53 else
55 else
54 # Everything is in place we can safely use the sha256 and materialized
56 # Everything is in place we can safely use the sha256 and materialized
55− calculateUseAll;
57+ calculateUseMaterialized;
56
58
57 # Build fully and check the hash and materialized versions
59 # Build fully and check the hash and materialized versions
58 checked = runCommand name {
60 checked = runCommand name {
@@ -119,17 +121,14 @@ let
119 # Make sure output files can be removed from the sandbox
121 # Make sure output files can be removed from the sandbox
120 chmod -R +w $out
122 chmod -R +w $out
121 '';
123 '';
122− calculateUseAll =
124+ calculateUseMaterialized =
123− # Skip right to expectedPath if it already exists
124− if materialized != null
125+ assert materialized != null;
125− then
126− assert __pathExists materialized;
126+ assert __pathExists materialized;
127− runCommand name hashArgs ''
127+ runCommand name (pkgs.lib.optionalAttrs (sha256 == null) hashArgs) ''
128− cp -r ${materialized} $out
128+ cp -r ${materialized} $out
129− # Make sure output files can be removed from the sandbox
129+ # Make sure output files can be removed from the sandbox
130− chmod -R +w $out
130+ chmod -R +w $out
131− ''
131+ '';
132− else calculateUseHash;
133
132
134 # Materialized location was specified, but the files are not there.
133 # Materialized location was specified, but the files are not there.
135 missingMaterialized = materialized != null && !__pathExists materialized;
134 missingMaterialized = materialized != null && !__pathExists materialized;
overlays/bootstrap.nix−3
@@ -386,7 +386,6 @@ in {
386 inherit (bootstrap.packages) cabal-install nix-tools hpack;
386 inherit (bootstrap.packages) cabal-install nix-tools hpack;
387 name = "alex"; version = "3.2.4";
387 name = "alex"; version = "3.2.4";
388 index-state = self.haskell-nix.internalHackageIndexState;
388 index-state = self.haskell-nix.internalHackageIndexState;
389− plan-sha256 = "1adn8s46msqm2rl6yf01z2r81maa2001qh441j491gpmc3ki36n0";
390 materialized = ../materialized/alex;
389 materialized = ../materialized/alex;
391 };
390 };
392 alex = bootstrap.packages.alex-project.hsPkgs.alex.components.exes.alex;
391 alex = bootstrap.packages.alex-project.hsPkgs.alex.components.exes.alex;
@@ -396,7 +395,6 @@ in {
396 inherit (bootstrap.packages) cabal-install nix-tools hpack;
395 inherit (bootstrap.packages) cabal-install nix-tools hpack;
397 name = "happy"; version = "1.19.11";
396 name = "happy"; version = "1.19.11";
398 index-state = self.haskell-nix.internalHackageIndexState;
397 index-state = self.haskell-nix.internalHackageIndexState;
399− plan-sha256 = "0swpwhlym4p3209qv90mfgq6zsaw99ipznm4pvd32mxzwq9s5q8i";
400 materialized = ../materialized/happy;
398 materialized = ../materialized/happy;
401 };
399 };
402 happy = bootstrap.packages.happy-project.hsPkgs.happy.components.exes.happy;
400 happy = bootstrap.packages.happy-project.hsPkgs.happy.components.exes.happy;
@@ -406,7 +404,6 @@ in {
406 inherit (bootstrap.packages) cabal-install nix-tools hpack;
404 inherit (bootstrap.packages) cabal-install nix-tools hpack;
407 name = "hscolour"; version = "1.24.4";
405 name = "hscolour"; version = "1.24.4";
408 index-state = self.haskell-nix.internalHackageIndexState;
406 index-state = self.haskell-nix.internalHackageIndexState;
409− plan-sha256 = "0cnkczsh1xy7cc60q3blwa51qrjhf5mc89s34y9ab3x702a26b75";
410 materialized = ../materialized/hscolour;
407 materialized = ../materialized/hscolour;
411 };
408 };
412 hscolour = bootstrap.packages.hscolour-project.hsPkgs.hscolour.components.exes.HsColour;
409 hscolour = bootstrap.packages.hscolour-project.hsPkgs.hscolour.components.exes.HsColour;
overlays/ghc-packages.nix+2−37
@@ -59,15 +59,11 @@ let
59 # (we need to upgrade `nix-tools` to Cabal 3 for them to work)
59 # (we need to upgrade `nix-tools` to Cabal 3 for them to work)
60 skipBroken = self.lib.filterAttrs (pkgName: _:
60 skipBroken = self.lib.filterAttrs (pkgName: _:
61 ghcName == "ghc865" || (pkgName != "base" && pkgName != "ghc-heap"));
61 ghcName == "ghc865" || (pkgName != "base" && pkgName != "ghc-heap"));
62− sha256 = ghc-boot-packages-nix-sha256."${ghcName}" or null;
63 materializedPath = ../materialized/ghc-boot-packages-nix + "/${ghcName}";
62 materializedPath = ../materialized/ghc-boot-packages-nix + "/${ghcName}";
64 in (self.haskell-nix.materialize ({
63 in (self.haskell-nix.materialize ({
65− inherit sha256;
66− materialized = if sha256 != null && __pathExists materializedPath
64+ materialized = if __pathExists materializedPath
67 then materializedPath
65 then materializedPath
68 else null;
66 else null;
69− sha256Arg = "ghc-boot-packages-nix-sha256";
70− reasonNotSafe = null;
71 }) (combineFiles "${ghcName}-boot-packages-nix" ".nix" (builtins.mapAttrs
67 }) (combineFiles "${ghcName}-boot-packages-nix" ".nix" (builtins.mapAttrs
72 (_: sdistAndNix: sdistAndNix.nix) (skipBroken bootPackages))));
68 (_: sdistAndNix: sdistAndNix.nix) (skipBroken bootPackages))));
73
69
@@ -89,14 +85,6 @@ let
89 iserv-proxy = "utils/iserv-proxy";
85 iserv-proxy = "utils/iserv-proxy";
90 };
86 };
91
87
92− # Hashes needed to make ghc-boot-packages use fixed output derivations
93− # for the nix files.
94− ghc-boot-packages-nix-sha256 = {
95− ghc865 = "0n5bsi67mczbwch8a3dwf58hkignb8qswv7h707dqgc43himvq3b";
96− ghc882 = "1wpvy0f2m7l3h8fz0iag3q8zj6j4i7732x1f0lkxnr2whnv88dfb";
97− ghc883 = "147l5a7vm8dgyb2wz692p3n3fsvq8wbjn5wnjhabdgw4mxw0c2mm";
98− };
99−
100 # The nix produced by `cabalProject` differs slightly depending on
88 # The nix produced by `cabalProject` differs slightly depending on
101 # what the platforms are. There are currently 3 possible outputs.
89 # what the platforms are. There are currently 3 possible outputs.
102 ghc-extra-projects-type =
90 ghc-extra-projects-type =
@@ -106,26 +94,6 @@ let
106 then "cross"
94 then "cross"
107 else "default";
95 else "default";
108
96
109− # Hashes needed to make ghc-extra-projects use fixed output derivations
110− # for the nix files.
111− ghc-extra-projects-sha256 = {
112− default = {
113− ghc865 = "12mj0fmm0b0jys6pb2l7l9w2w5as5fiqkfav81mjlz9ic1rkqk92";
114− ghc882 = "0q4v1iryvd5xvnkb1s02a3v6x0lj73r8bsfxrs9bxipk22bcksm9";
115− ghc883 = "0dy6isqz41c0di5yf1mhyp0nbp6aw5m947b54l5074lkmc4f5alb";
116− };
117− windows = {
118− ghc865 = "1jizwsnmdr2iglispm9wmhhbdh2gh6yfvk8x1jbj0sk9pq21xwap";
119− ghc882 = "09ji5548bsqqa7iwphjxmc5i067ya6zh0v1hfls9acfrxax0sfgm";
120− ghc883 = "0gliadn1nj1i5y5hjz280h1kgzql97yfh4gy63k2g7xsldmzb57b";
121− };
122− cross = {
123− ghc865 = "10bckrm3qi1vymncjiv534b8nb8bgix8w8y91543xxwhzpmwml3f";
124− ghc882 = "0hamwh6x0vfki2c4kj132x2c2hqvr1r735cfd4yrygzf86drmyf0";
125− ghc883 = "0v8wq8i82c329kzi3yzv6ny63yaggbzdaaxbbklxwg16fawqn08p";
126− };
127− };
128−
129# Given the ghc-extra-pkgs, we'll create a cabal.project
97# Given the ghc-extra-pkgs, we'll create a cabal.project
130# that contains all of them. And then we call cabalProject
98# that contains all of them. And then we call cabalProject
131# on it to generate the necessary cabal project exposing all
99# on it to generate the necessary cabal project exposing all
@@ -200,11 +168,8 @@ in rec {
200 name = "ghc-extra-projects-${ghc-extra-projects-type}-${ghcName}";
168 name = "ghc-extra-projects-${ghc-extra-projects-type}-${ghcName}";
201 src = proj;
169 src = proj;
202 index-state = self.haskell-nix.internalHackageIndexState;
170 index-state = self.haskell-nix.internalHackageIndexState;
203− plan-sha256 =
204− ghc-extra-projects-sha256."${ghc-extra-projects-type}"."${ghcName}"
205− or null;
206 materialized =
171 materialized =
207− if ghc-extra-projects-sha256."${ghc-extra-projects-type}" ? "${ghcName}"
172+ if __pathExists materializedPath
208 then materializedPath
173 then materializedPath
209 else null;
174 else null;
210 ghc = self.buildPackages.haskell-nix.compiler.${ghcName};
175 ghc = self.buildPackages.haskell-nix.compiler.${ghcName};