Skip to content

Commit bdaee63

Browse files
committed
wip: useCabalFromGHC, look into ghc environment files
1 parent b78685a commit bdaee63

17 files changed

+218
-433
lines changed

.envrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

builder/make-config-files.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
let
66
# Sort and remove duplicates from nonReinstallablePkgs.
77
# That way changes to the order of nonReinstallablePkgs does not require rebuilds.
8-
nonReinstallablePkgs' = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x));
8+
nonReinstallablePkgs' = let x = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x)); in __trace x x;
99

1010
ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;
1111

@@ -151,6 +151,7 @@ let
151151
152152
for p in "''${pkgsHostTarget[@]}"; do
153153
if [ -e $p/envDep ]; then
154+
echo "But not here"
154155
cat $p/envDep >> $configFiles/ghc-environment
155156
fi
156157
${ lib.optionalString component.doExactConfig ''
@@ -221,7 +222,7 @@ let
221222
done
222223
'' + ''
223224
${target-pkg} -v0 --package-db $configFiles/${packageCfgDir} recache
224-
'';
225+
'';
225226
drv = runCommand "${ghc.targetPrefix}${fullName}-config" {
226227
nativeBuildInputs = [ghc];
227228
propagatedBuildInputs = libDeps;

flake.lock

Lines changed: 72 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
url = "github:haskell/cabal/3.6";
2323
flake = false;
2424
};
25+
26+
hackage-db = {
27+
url = "github:michaelpj/hackage-db/83f819cb08742d3c86a83b407d45c1f6c1c7e299";
28+
flake = false;
29+
};
2530
};
2631

2732
outputs =

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ let
7373
# nix module system for `nix-tools-unchecked` and `cabal-install-unchecked`.
7474
nix-tools = if args.nix-tools or null != null
7575
then args.nix-tools
76-
else evalPackages.haskell-nix.nix-tools-unchecked;
76+
else evalPackages.haskell-nix.nix-tools;
7777
cabal-install = nix-tools.exes.cabal;
7878
forName = pkgs.lib.optionalString (name != null) (" for " + name);
7979
nameAndSuffix = suffix: if name == null then suffix else name + "-" + suffix;
@@ -423,7 +423,7 @@ let
423423
# without the source available (we cleanSourceWith'd it),
424424
# this may not produce the right result.
425425
if supportHpack
426-
then ''
426+
then ''
427427
echo No .cabal file found, running hpack on $hpackFile
428428
hpack $hpackFile
429429
''
@@ -451,7 +451,7 @@ let
451451
# some packages that will be excluded by `index-state-max`
452452
# which is used by cabal (cached-index-state >= index-state-max).
453453
dotCabal {
454-
inherit cabal-install nix-tools extra-hackage-tarballs;
454+
inherit nix-tools extra-hackage-tarballs;
455455
extra-hackage-repos = fixedProject.repos;
456456
index-state = cached-index-state;
457457
sha256 = index-sha256-found;
@@ -462,6 +462,7 @@ let
462462
# packages used by the solver (cached-index-state >= index-state-max).
463463
pkgs.lib.optionalString (index-state != null) "--index-state=${index-state}"
464464
} \
465+
-v3 \
465466
-w ${
466467
# We are using `-w` rather than `--with-ghc` here to override
467468
# the `with-compiler:` in the `cabal.project` file.

modules/cabal-project.nix

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ in {
1919
description = "The name of the ghc compiler to use eg. \"ghc884\"";
2020
# Map short version names to the latest GHC version.
2121
# TODO: perhaps combine this with the `latestVer` mapping in `overlays/boostrap.nix`.
22-
apply = name:
23-
let
24-
fullName = pkgs.haskell-nix.resolve-compiler-name name;
25-
ghc910FullName = pkgs.haskell-nix.resolve-compiler-name "ghc910X";
26-
ghc911FullName = pkgs.haskell-nix.resolve-compiler-name "ghc911";
27-
in
28-
# cabal-install from hackage (3.10.1.0) does not build with GHC HEAD
29-
if builtins.elem fullName [ ghc910FullName ghc911FullName ] && config.name == "cabal-install" && (builtins.elem config.version ["3.10.1.0" "3.10.2.0" "3.10.2.1"])
30-
then "ghc964"
31-
else pkgs.haskell-nix.resolve-compiler-name name;
22+
# apply = name:
23+
# let
24+
# fullName = pkgs.haskell-nix.resolve-compiler-name name;
25+
# ghc910FullName = pkgs.haskell-nix.resolve-compiler-name "ghc910X";
26+
# ghc911FullName = pkgs.haskell-nix.resolve-compiler-name "ghc911";
27+
# in
28+
# # cabal-install from hackage (3.10.1.0) does not build with GHC HEAD
29+
# if builtins.elem fullName [ ghc910FullName ghc911FullName ] && config.name == "cabal-install" && (builtins.elem config.version ["3.10.1.0" "3.10.2.0" "3.10.2.1"])
30+
# then "ghc964"
31+
# else pkgs.haskell-nix.resolve-compiler-name name;
3232
};
3333
compilerSelection = mkOption {
3434
type = unspecified;

nix-tools/flake.nix

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,13 @@
1717

1818
compiler = "ghc981";
1919

20-
nix-tools-overlays = final: prev: {
21-
haskell = prev.haskell // {
22-
packages = prev.haskell.packages // {
23-
"${compiler}" = prev.haskell.packages."${compiler}".override
24-
(old: {
25-
overrides = final.lib.fold final.lib.composeExtensions
26-
(old.overrides or (_: _: { })) [
27-
(hfinal: hprev:
28-
let
29-
fetchFromHackage = pname: version: hash:
30-
hfinal.callHackageDirect {
31-
pkg = pname;
32-
ver = version;
33-
sha256 = hash;
34-
};
35-
ps-cabal-install-solver = (fetchFromHackage "cabal-install-solver" "3.10.2.1" "sha256-wNwp42fiEketjcKJwhv5etP5/bVGlDitnMryTLX+Z74=") {};
36-
ps-cabal-install = (fetchFromHackage "cabal-install" "3.10.2.1" "sha256-encWM587n+atIrbjHaNjNeavBoxmMsI1QXDS5AtOLoo=") {Cabal-described = null; Cabal-QuickCheck = null; Cabal-tree-diff = null; cabal-install-solver = ps-cabal-install-solver;};
37-
in {
38-
ps-cabal-install = ps-cabal-install;
39-
ps-cabal-install-solver = ps-cabal-install-solver;
40-
})
41-
(hfinal: hprev:
42-
{
43-
nix-tools = final.haskell.lib.dontCheck (final.haskell.lib.markUnbroken (hfinal.callCabal2nix "nix-tools" ./nix-tools {
44-
cabal-install = hfinal.ps-cabal-install;
45-
cabal-install-solver = hfinal.ps-cabal-install-solver;
46-
}));
47-
48-
hackage-db = hfinal.callCabal2nix "hackage-db" "${inputs.hackage-db}" {};
49-
})
50-
];
51-
});
52-
};
53-
};
54-
};
55-
5620
# keep it simple (from https://ayats.org/blog/no-flake-utils/)
5721
forAllSystems = f:
5822
nixpkgs.lib.genAttrs systems (system:
5923
f (import nixpkgs {
6024
inherit system;
6125
overlays = [
62-
nix-tools-overlays
26+
(import ./overlay.nix { hackage-db-src = "${inputs.hackage-db}"; })
6327
];
6428
}));
6529

@@ -68,6 +32,7 @@
6832
packages = forAllSystems (pkgs:
6933
{
7034
nix-tools = pkgs.haskell.packages.ghc981.nix-tools;
35+
pkgs = pkgs;
7136
});
7237
};
7338

0 commit comments

Comments
 (0)