Skip to content

Commit 0acd595

Browse files
committed
Merge branch 'hkm/use-cabal-3.8' into hkm/combined-derivations
# Conflicts: # builder/hspkg-builder.nix # lib/call-cabal-project-to-nix.nix
2 parents 5f32a61 + 2611a66 commit 0acd595

File tree

172 files changed

+17083
-8313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+17083
-8313
lines changed

flake.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+42-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{ pkgs, runCommand, cacert, index-state-hashes, haskellLib }@defaults:
22
let readIfExists = src: fileName:
3+
# Using origSrcSubDir bypasses any cleanSourceWith.
34
let origSrcDir = src.origSrcSubDir or src;
45
in
56
if builtins.elem ((__readDir origSrcDir)."${fileName}" or "") ["regular" "symlink"]
@@ -65,6 +66,7 @@ in
6566
# any plutus-apps input being used for a
6667
# package.
6768
, evalPackages
69+
, pkgconfSelector ? (_: [])
6870
, supportHpack ? false # Run hpack on package.yaml files with no .cabal file
6971
, ...
7072
}@args:
@@ -123,26 +125,38 @@ let
123125
type == "directory" ||
124126
pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); };
125127

126-
# Using origSrcSubDir bypasses any cleanSourceWith so that it will work when
127-
# access to the store is restricted. If origSrc was already in the store
128-
# you can pass the project in as a string.
129-
rawCabalProject =
130-
if cabalProject != null
131-
then cabalProject + (
132-
if cabalProjectLocal != null
133-
then ''
134-
135-
-- Added from cabalProjectLocal argument to cabalProject
136-
${cabalProjectLocal}
137-
''
138-
else ""
139-
)
140-
else null;
141-
142-
cabalProjectIndexState =
143-
if rawCabalProject != null
144-
then pkgs.haskell-nix.haskellLib.parseIndexState rawCabalProject
145-
else null;
128+
# When there is no `cabal.project` file `cabal-install` behaves as if there was
129+
# one containing `packages: ./*.cabal`. Even if there is a `cabal.project.local`
130+
# containing some other `packages:`, it still includes `./*.cabal`.
131+
#
132+
# We could write to `cabal.project.local` instead of `cabal.project` when
133+
# `cabalProject == null`. However then `cabal-install` will look in parent
134+
# directories for a `cabal.project` file. That would complicate reasoning about
135+
# the relative directories of packages.
136+
#
137+
# Instead we treat `cabalProject == null` as if it was `packages: ./*.cabal`.
138+
#
139+
# See: https://github.com/input-output-hk/haskell.nix/pull/1588
140+
# https://github.com/input-output-hk/haskell.nix/pull/1639
141+
#
142+
rawCabalProject = ''
143+
${
144+
if cabalProject == null
145+
then ''
146+
-- Included to match the implicit project used by `cabal-install`
147+
packages: ./*.cabal
148+
''
149+
else cabalProject
150+
}
151+
${
152+
pkgs.lib.optionalString (cabalProjectLocal != null) ''
153+
-- Added from `cabalProjectLocal` argument to the `cabalProject` function
154+
${cabalProjectLocal}
155+
''
156+
}
157+
'';
158+
159+
cabalProjectIndexState = pkgs.haskell-nix.haskellLib.parseIndexState rawCabalProject;
146160

147161
index-state-found =
148162
if index-state != null
@@ -155,6 +169,8 @@ let
155169

156170
index-state-pinned = index-state != null || cabalProjectIndexState != null;
157171

172+
pkgconfPkgs = import ./pkgconf-nixpkgs-map.nix pkgs;
173+
158174
in
159175
assert (if index-state-found == null
160176
then throw "No index state passed and none found in ${cabalProjectFileName}" else true);
@@ -295,10 +311,7 @@ let
295311
);
296312
};
297313

298-
fixedProject =
299-
if rawCabalProject == null
300-
then { sourceRepos = []; repos = {}; extra-hackages = []; makeFixedProjectFile = ""; replaceLocations = ""; }
301-
else replaceSourceRepos rawCabalProject;
314+
fixedProject = replaceSourceRepos rawCabalProject;
302315

303316
# The use of the actual GHC can cause significant problems:
304317
# * For hydra to assemble a list of jobs from `components.tests` it must
@@ -320,14 +333,14 @@ let
320333
# when `checkMaterialization` is set.
321334
dummy-ghc-data =
322335
let
323-
materialized = ../materialized/dummy-ghc + "/${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}";
336+
materialized = ../materialized/dummy-ghc + "/${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}"
337+
+ pkgs.lib.optionalString (builtins.compareVersions ghc.version "8.10" < 0 && ghc.targetPrefix == "" && builtins.compareVersions pkgs.lib.version "22.05" < 0) "-old";
324338
in pkgs.haskell-nix.materialize ({
325339
sha256 = null;
326340
sha256Arg = "sha256";
327341
materialized = if __pathExists materialized
328342
then materialized
329-
else __trace ("WARNING: No materialized dummy-ghc-data for "
330-
+ "${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}.")
343+
else __trace "WARNING: No materialized dummy-ghc-data. mkdir ${toString materialized}"
331344
null;
332345
reasonNotSafe = null;
333346
} // pkgs.lib.optionalAttrs (checkMaterialization != null) {
@@ -456,8 +469,9 @@ let
456469
}) (evalPackages.runCommand (nameAndSuffix "plan-to-nix-pkgs") {
457470
nativeBuildInputs = [
458471
nix-tools.exes.plan-to-nix
459-
dummy-ghc dummy-ghc-pkg cabal-install evalPackages.rsync evalPackages.gitMinimal ]
472+
dummy-ghc dummy-ghc-pkg cabal-install evalPackages.rsync evalPackages.gitMinimal evalPackages.pkgconfig ]
460473
++ pkgs.lib.optional supportHpack nix-tools.exes.hpack;
474+
buildInputs = pkgconfSelector pkgconfPkgs;
461475
# Needed or stack-to-nix will die on unicode inputs
462476
LOCALE_ARCHIVE = pkgs.lib.optionalString (evalPackages.stdenv.buildPlatform.libc == "glibc") "${evalPackages.glibcLocales}/lib/locale/locale-archive";
463477
LANG = "en_US.UTF-8";

lib/ghcjs-project.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
if (builtins.compareVersions ghcjsVersion "8.10.0.0" >= 0)
4040
then pkgs.haskell-nix.tool compiler-nix-name "cabal" {
4141
index-state = pkgs.haskell-nix.internalHackageIndexState;
42-
version = "3.6.2.0";
42+
version = "3.8.1.0";
4343
materialized = ../materialized/ghcjs/cabal + "/${compiler-nix-name}";
4444
}
4545
else pkgs.haskell-nix.tool compiler-nix-name "cabal" {
@@ -48,7 +48,7 @@
4848
# Cabal 3.2.1.0 no longer supports he mix of `cabal-version`,
4949
# lack of `custom-setup` and `v1-install` used by ghcjs boot.
5050
cabalProjectLocal = ''
51-
constraints: Cabal <3.2.1.0
51+
constraints: Cabal <3.2.1.0, Cabal-syntax <0
5252
'';
5353
materialized = ../materialized/ghcjs/cabal + "/${compiler-nix-name}";
5454
}

lib/materialize.nix

+12-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,18 @@ let
8383
fi
8484
'')
8585
+ (
86-
let fixHint = if builtins.hasContext (toString materialized)
87-
then "To fix run: ${updateMaterialized}"
88-
else "To fix check you are in the right directory and run: ${generateMaterialized} ${__head (__match "/nix/store/[^/]*/(.*)" (toString materialized))}";
86+
let
87+
# When the materialized location is already in the store updateMaterialized
88+
# will not work, but generateMaterialized will. We can use this regex to get
89+
# a good idea of what directory might be (relative to some unknown parent).
90+
# In the regex `[^/]*/?` skips the name of the /nix/store sub directory.
91+
matches = __match "${builtins.storeDir}/[^/]*/?(.*)" (toString materialized);
92+
fixHint =
93+
if matches == null
94+
then "To fix run: ${updateMaterialized}" # Not in store so updateMaterialized may work
95+
else if __head matches == ""
96+
then "To fix run: ${generateMaterialized} <materialized files location>"
97+
else "To fix check you are in the right directory and run: ${generateMaterialized} ${__head matches}";
8998
in if materialized != null && !__pathExists materialized
9099
then ''
91100
echo "Materialized nix used for ${name} is missing. ${fixHint}" >> $ERR

lib/pkgconf-nixpkgs-map.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ pkgs:
143143
"sctp" = [ pkgs."lksctp-tools" ]; # This is linux-specific, we should create a common attribute if we ever add sctp support for other systems.
144144
"sdl2" = [ pkgs."SDL2" ];
145145
"sndfile" = [ pkgs."libsndfile" ];
146-
"sodium" = [ pkgs."libsodium" ];
146+
"sodium" = [ pkgs."libsodium".dev ];
147+
"libsodium" = [ pkgs."libsodium".dev ];
147148
"sqlite3" = [ pkgs."sqlite" ];
148149
"ssh2" = [ pkgs."libssh2" ];
149150
"statgrab" = [ pkgs."libstatgrab" ];

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.10.5-x86_64-linux/ghc-pkg/dump-global

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.10.5-x86_64-linux/ghc/info

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.10.6-x86_64-linux/ghc-pkg/dump-global

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.10.6-x86_64-linux/ghc/info

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.10.7-x86_64-linux/ghc-pkg/dump-global

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.10.7-x86_64-linux/ghc/info

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.8.4-x86_64-linux/ghc-pkg/dump-global

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/aarch64-unknown-linux-gnu-aarch64-unknown-linux-gnu-ghc-8.8.4-x86_64-linux/ghc/info

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)