Skip to content

Commit e4d75d6

Browse files
authored
Allow materialized only (#563)
This change allows for just the materialized argument to be passed and removes the sha256 values for haskell.nix's own materialized nix files.
1 parent e08db6b commit e4d75d6

File tree

3 files changed

+17
-56
lines changed

3 files changed

+17
-56
lines changed

lib/materialize.nix

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{ pkgs, nix, runCommand, checkMaterialization }@defaults:
2-
{ sha256
3-
, sha256Arg # Name of the sha256 argument for more meaningful
2+
{ sha256 ? null # Has to make this a fixed output derivation
3+
, sha256Arg ? "sha256"
4+
# Name of the sha256 argument for more meaningful
45
# error messages when checking the materialization.
56
, materialized # null or path where to find materialized version of
67
# the output. If this is set but does not exist
78
# the derivation will fail but with a message
89
# advising how to populate it.
9-
, reasonNotSafe # Some times there a reasont the derivation will
10+
, reasonNotSafe ? null
11+
# Some times there a reasont the derivation will
1012
# not produce output that can be safely materialized.
1113
# Set this to a string explaining why and materialization
1214
# will not be used (if sha256 was set an error will be
@@ -37,7 +39,7 @@ let
3739
# Warn the user if they tried to pin stuff down when it is not safe
3840
traceIgnoringSha256 reasonNotSafe
3941
(traceIgnoringMaterialized reasonNotSafe calculateNoHash)
40-
else if sha256 == null
42+
else if sha256 == null && materialized == null
4143
then
4244
# Let the user know how to calculate a sha256 to use to make this
4345
# a fixed output derivation.
@@ -52,7 +54,7 @@ let
5254
calculateUseHash
5355
else
5456
# Everything is in place we can safely use the sha256 and materialized
55-
calculateUseAll;
57+
calculateUseMaterialized;
5658

5759
# Build fully and check the hash and materialized versions
5860
checked = runCommand name {
@@ -119,17 +121,14 @@ let
119121
# Make sure output files can be removed from the sandbox
120122
chmod -R +w $out
121123
'';
122-
calculateUseAll =
123-
# Skip right to expectedPath if it already exists
124-
if materialized != null
125-
then
126-
assert __pathExists materialized;
127-
runCommand name hashArgs ''
128-
cp -r ${materialized} $out
129-
# Make sure output files can be removed from the sandbox
130-
chmod -R +w $out
131-
''
132-
else calculateUseHash;
124+
calculateUseMaterialized =
125+
assert materialized != null;
126+
assert __pathExists materialized;
127+
runCommand name (pkgs.lib.optionalAttrs (sha256 == null) hashArgs) ''
128+
cp -r ${materialized} $out
129+
# Make sure output files can be removed from the sandbox
130+
chmod -R +w $out
131+
'';
133132

134133
# Materialized location was specified, but the files are not there.
135134
missingMaterialized = materialized != null && !__pathExists materialized;

overlays/bootstrap.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ in {
386386
inherit (bootstrap.packages) cabal-install nix-tools hpack;
387387
name = "alex"; version = "3.2.4";
388388
index-state = self.haskell-nix.internalHackageIndexState;
389-
plan-sha256 = "1adn8s46msqm2rl6yf01z2r81maa2001qh441j491gpmc3ki36n0";
390389
materialized = ../materialized/alex;
391390
};
392391
alex = bootstrap.packages.alex-project.hsPkgs.alex.components.exes.alex;
@@ -396,7 +395,6 @@ in {
396395
inherit (bootstrap.packages) cabal-install nix-tools hpack;
397396
name = "happy"; version = "1.19.11";
398397
index-state = self.haskell-nix.internalHackageIndexState;
399-
plan-sha256 = "0swpwhlym4p3209qv90mfgq6zsaw99ipznm4pvd32mxzwq9s5q8i";
400398
materialized = ../materialized/happy;
401399
};
402400
happy = bootstrap.packages.happy-project.hsPkgs.happy.components.exes.happy;
@@ -406,7 +404,6 @@ in {
406404
inherit (bootstrap.packages) cabal-install nix-tools hpack;
407405
name = "hscolour"; version = "1.24.4";
408406
index-state = self.haskell-nix.internalHackageIndexState;
409-
plan-sha256 = "0cnkczsh1xy7cc60q3blwa51qrjhf5mc89s34y9ab3x702a26b75";
410407
materialized = ../materialized/hscolour;
411408
};
412409
hscolour = bootstrap.packages.hscolour-project.hsPkgs.hscolour.components.exes.HsColour;

overlays/ghc-packages.nix

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,11 @@ let
5959
# (we need to upgrade `nix-tools` to Cabal 3 for them to work)
6060
skipBroken = self.lib.filterAttrs (pkgName: _:
6161
ghcName == "ghc865" || (pkgName != "base" && pkgName != "ghc-heap"));
62-
sha256 = ghc-boot-packages-nix-sha256."${ghcName}" or null;
6362
materializedPath = ../materialized/ghc-boot-packages-nix + "/${ghcName}";
6463
in (self.haskell-nix.materialize ({
65-
inherit sha256;
66-
materialized = if sha256 != null && __pathExists materializedPath
64+
materialized = if __pathExists materializedPath
6765
then materializedPath
6866
else null;
69-
sha256Arg = "ghc-boot-packages-nix-sha256";
70-
reasonNotSafe = null;
7167
}) (combineFiles "${ghcName}-boot-packages-nix" ".nix" (builtins.mapAttrs
7268
(_: sdistAndNix: sdistAndNix.nix) (skipBroken bootPackages))));
7369

@@ -89,14 +85,6 @@ let
8985
iserv-proxy = "utils/iserv-proxy";
9086
};
9187

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-
10088
# The nix produced by `cabalProject` differs slightly depending on
10189
# what the platforms are. There are currently 3 possible outputs.
10290
ghc-extra-projects-type =
@@ -106,26 +94,6 @@ let
10694
then "cross"
10795
else "default";
10896

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-
12997
# Given the ghc-extra-pkgs, we'll create a cabal.project
13098
# that contains all of them. And then we call cabalProject
13199
# on it to generate the necessary cabal project exposing all
@@ -200,11 +168,8 @@ in rec {
200168
name = "ghc-extra-projects-${ghc-extra-projects-type}-${ghcName}";
201169
src = proj;
202170
index-state = self.haskell-nix.internalHackageIndexState;
203-
plan-sha256 =
204-
ghc-extra-projects-sha256."${ghc-extra-projects-type}"."${ghcName}"
205-
or null;
206171
materialized =
207-
if ghc-extra-projects-sha256."${ghc-extra-projects-type}" ? "${ghcName}"
172+
if __pathExists materializedPath
208173
then materializedPath
209174
else null;
210175
ghc = self.buildPackages.haskell-nix.compiler.${ghcName};

0 commit comments

Comments
 (0)