Skip to content

Commit 6bb68c6

Browse files
committed
Fix hadrian eval time dependency on buildPackages.srcOnly
1 parent 468ef7d commit 6bb68c6

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

compiler/ghc/default.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,18 @@ let
297297
subDir = "hadrian";
298298
includeSiblings = true;
299299
};
300+
# When building the plan we do not need a patched version
301+
# of the source and `buildPackages.srcOnly` requires introduces
302+
# a dependency on a build machine.
303+
evalSrc = haskell-nix.haskellLib.cleanSourceWith {
304+
src = {
305+
name = "hadrian";
306+
outPath = src;
307+
filterPath = { path, ... }: path;
308+
};
309+
subDir = "hadrian";
310+
includeSiblings = true;
311+
};
300312
};
301313

302314
hadrian = hadrianProject.hsPkgs.hadrian.components.exes.hadrian;

lib/call-cabal-project-to-nix.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{ pkgs, cacert, index-state-hashes, haskellLib }:
22
{ name ? src.name or null # optional name for better error messages
33
, src
4+
, evalSrc ? src
45
, materialized-dir ? ../materialized
56
, compiler-nix-name # The name of the ghc compiler to use eg. "ghc884"
67
, index-state ? null # Hackage index-state, eg. "2019-10-10T00:00:00Z"
@@ -94,13 +95,13 @@ in let
9495
ghc = if ghc' ? latestVersion
9596
then __trace "WARNING: ${ghc'.version} is out of date, consider using upgrading to ${ghc'.latestVersion}." ghc'
9697
else ghc';
97-
subDir' = src.origSubDir or "";
98+
subDir' = evalSrc.origSubDir or "";
9899
subDir = pkgs.lib.strings.removePrefix "/" subDir';
99100

100101
cleanedSource = haskellLib.cleanSourceWith {
101102
name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files";
102-
src = src.origSrc or src;
103-
filter = path: type: (!(src ? filter) || src.filter path type) && (
103+
src = evalSrc.origSrc or evalSrc;
104+
filter = path: type: (!(evalSrc ? filter) || evalSrc.filter path type) && (
104105
type == "directory" ||
105106
pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); };
106107

modules/cabal-project.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ in {
5656
};
5757
cabalProject = mkOption {
5858
type = nullOr lines;
59-
default = readIfExists config.src config.cabalProjectFileName;
59+
default = readIfExists config.evalSrc config.cabalProjectFileName;
6060
};
6161
cabalProjectLocal = mkOption {
6262
type = nullOr lines;
63-
default = readIfExists config.src "${config.cabalProjectFileName}.local";
63+
default = readIfExists config.evalSrc "${config.cabalProjectFileName}.local";
6464
};
6565
cabalProjectFreeze = mkOption {
6666
type = nullOr lines;
67-
default = readIfExists config.src "${config.cabalProjectFileName}.freeze";
67+
default = readIfExists config.evalSrc "${config.cabalProjectFileName}.freeze";
6868
};
6969
ghc = mkOption {
7070
type = nullOr package;

modules/project-common.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ with lib.types;
7575
};
7676
'';
7777
};
78+
evalSrc = mkOption {
79+
type = either path package;
80+
default = config.src;
81+
description = ''
82+
Allows a different version of the src to be used at eval time.
83+
This is useful when building the source may require a build machine.
84+
To avoid an eval time dependency on a build machine set `evalSrc`
85+
to either:
86+
* A version of the source built using `evalPackages`
87+
* A version of the source that does not require building
88+
'';
89+
};
7890
hsPkgs = lib.mkOption {
7991
type = lib.types.unspecified;
8092
};

0 commit comments

Comments
 (0)