Skip to content

Commit 60afd88

Browse files
committed
WIP
1 parent a90525a commit 60afd88

File tree

4 files changed

+71
-65
lines changed

4 files changed

+71
-65
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
{ pkgs, runCommand, cacert, index-state-hashes, haskellLib }:
1+
{ pkgs
2+
, cacert
3+
, index-state-hashes
4+
, haskell-nix
5+
}:
6+
7+
let inherit (haskell-nix) haskellLib;
8+
in
9+
210
{ name ? src.name or null # optional name for better error messages
311
, src
412
, materialized-dir ? ../materialized
@@ -65,7 +73,7 @@
6573
, ...
6674
}@args:
6775
let
68-
inherit (evalPackages.haskell-nix) materialize dotCabal;
76+
inherit (evalPackages.haskell-nix) dummy-ghc-pkg-dump materialize dotCabal;
6977

7078
# These defaults are here rather than in modules/cabal-project.nix to make them
7179
# lazy enough to avoid infinite recursion issues.
@@ -102,6 +110,7 @@ in let
102110
ghc = if ghc' ? latestVersion
103111
then __trace "WARNING: ${ghc'.version} is out of date, consider using upgrading to ${ghc'.latestVersion}." ghc'
104112
else ghc';
113+
105114
subDir' = src.origSubDir or "";
106115
subDir = pkgs.lib.strings.removePrefix "/" subDir';
107116

@@ -295,8 +304,6 @@ let
295304

296305
fixedProject = replaceSourceRepos rawCabalProject;
297306

298-
ghcSrc = (ghc.raw-src or ghc.buildGHC.raw-src) evalPackages;
299-
300307
platformString = p: with p.parsed; "${cpu.name}-${vendor.name}-${kernel.name}";
301308

302309
# Dummy `ghc` that uses the captured output
@@ -366,11 +373,6 @@ let
366373
'';
367374
};
368375

369-
dummy-ghc-pkg-dump = evalPackages.callPackage ./dummy-ghc-pkg-dump {
370-
ghc-src = (ghc.raw-src or ghc.buildGHC.raw-src) evalPackages;
371-
ghc-version = ghc.version;
372-
};
373-
374376
# Dummy `ghc-pkg` that uses the captured output
375377
dummy-ghc-pkg = evalPackages.writeTextFile {
376378
name = "dummy-pkg-" + ghc.name;
@@ -388,7 +390,12 @@ let
388390
;;
389391
''}
390392
'dump --global -v0')
391-
cat ${dummy-ghc-pkg-dump}
393+
cat ${
394+
dummy-ghc-pkg-dump {
395+
ghc-src = (ghc.raw-src or ghc.buildGHC.raw-src) evalPackages;
396+
ghc-version = ghc.version;
397+
}
398+
}
392399
;;
393400
*)
394401
echo "Unknown argument '$*'. " >&2

lib/dummy-ghc-pkg-dump/configure.ac

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/dummy-ghc-pkg-dump/default.nix

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,63 @@
11
{
22
autoconf,
3-
cabal2json,
43
coreutils,
54
findutils,
6-
ghc-src,
7-
ghc-version,
5+
haskell-nix,
86
jq,
97
lib,
108
runCommand,
119
stdenv,
10+
writeText,
1211
}:
1312

13+
let
14+
inherit (haskell-nix.nix-tools-unchecked.exes) cabal2json;
15+
in
16+
17+
{ ghc-src, ghc-version }:
18+
1419
let
1520
ghc-m4-src = builtins.path {
1621
filter = path: type: lib.hasPrefix "${ghc-src}/m4" path;
1722
path = ghc-src;
1823
name = "ghc-src-m4";
1924
};
2025

26+
configure-ac = writeText "configure.ac" ''
27+
m4_include([fp_check_prog.m4])
28+
m4_include([fp_prog_find.m4])
29+
m4_include([fp_prog_sort.m4])
30+
m4_include([fp_setup_project_version.m4])
31+
32+
AC_INIT([The Glorious Glasgow Haskell Compilation System],
33+
[${ghc-version}],
34+
[glasgow-haskell-bugs@haskell.org],
35+
[ghc])
36+
37+
# Set this to YES for a released version, otherwise NO
38+
: ''${RELEASE=NO}
39+
40+
dnl ** Make sure we do not have a bogus source directory
41+
AC_CONFIG_SRCDIR(ghc/Main.hs)
42+
43+
dnl ----------------------------------------------------------
44+
dnl ** Find unixy sort and find commands,
45+
dnl ** which are needed by FP_SETUP_PROJECT_VERSION
46+
47+
FP_PROG_FIND
48+
FP_PROG_SORT
49+
50+
dnl ----------------------------------------------------------
51+
pushd ''${srcdir}
52+
FP_SETUP_PROJECT_VERSION
53+
popd
54+
55+
dnl ** Output code to perform substitutions
56+
AC_CONFIG_FILES
57+
58+
AC_OUTPUT
59+
'';
60+
2161
configure =
2262
runCommand "dummy-ghc-configure"
2363
{
@@ -28,15 +68,9 @@ let
2868
];
2969
}
3070
''
31-
set -euo pipefail
32-
autoconf --warnings all --include "${ghc-m4-src}/m4" --output=$out ${./configure.ac}
71+
autoconf --warnings all --include "${ghc-m4-src}/m4" --output=$out ${configure-ac}
3372
'';
3473

35-
# cabal2json = builtins.fetchClosure {
36-
# fromStore = "https://cache.zw3rk.com";
37-
# fromPath = /nix/store/q1kqwvqmwqcqaq82gaf951mq39v4sc91-Cabal-syntax-json-exe-cabal2json-0.1.0.0;
38-
# };
39-
4074
cabal2json-flags =
4175
with stdenv.targetPlatform;
4276
lib.cli.toGNUCommandLineShell { } {
@@ -60,16 +94,16 @@ let
6094
cd $out
6195
6296
# Run configure script (only for the project version)
63-
${configure} --srcdir=${ghc-src} PACKAGE_VERSION=${ghc-version}
97+
${configure} --srcdir=${ghc-src}
6498
6599
# Copy the cabal.in files
66100
pushd ${ghc-src}
67101
cp --no-preserve all --parents */*.cabal */*.cabal.in libraries/*/*.cabal libraries/*/*.cabal.in "$out"
68102
popd
69103
70104
# Substitute config variables in the cabal files
71-
FILES=( **/*.cabal.in )
72-
./config.status $(printf -- '--file %s ' "''${FILES[@]%.in}")
105+
CABAL_IN=( **/*.cabal.in )
106+
./config.status $(printf -- '--file %s ' "''${CABAL_IN[@]%.in}")
73107
74108
# Convert to json
75109
for f in **/*.cabal; do

overlays/haskell.nix

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ final: prev: {
167167
};
168168

169169
# Package sets for all stackage snapshots.
170-
snapshots = import ../snapshots.nix { inherit (final) lib ghc-boot-packages; inherit mkPkgSet stackage excludeBootPackages; };
170+
snapshots = import ../snapshots.nix {
171+
inherit (final) lib ghc-boot-packages;
172+
inherit mkPkgSet stackage excludeBootPackages;
173+
};
174+
171175
# Pick a recent LTS snapshot to be our "default" package set.
172176
haskellPackages =
173177
if final.stdenv.targetPlatform.isAarch64 && final.stdenv.buildPlatform.isAarch64
@@ -595,19 +599,12 @@ final: prev: {
595599

596600
};
597601

598-
dummy-ghc-pkg-dump = final.callPackage ../lib/dummy-ghc-pkg-dump {
599-
# FIXME: just for testing
600-
ghc-version = final.ghc.version;
601-
ghc-src = final.ghc.src;
602-
};
602+
dummy-ghc-pkg-dump = final.callPackage ../lib/dummy-ghc-pkg-dump { };
603603

604604
# Takes a haskell src directory runs cabal new-configure and plan-to-nix.
605605
# Resulting nix files are added to nix-plan subdirectory.
606-
callCabalProjectToNix = import ../lib/call-cabal-project-to-nix.nix {
606+
callCabalProjectToNix = final.buildPackages.callPackage ../lib/call-cabal-project-to-nix.nix {
607607
index-state-hashes = import indexStateHashesPath;
608-
inherit (final.buildPackages.haskell-nix) haskellLib;
609-
pkgs = final.buildPackages.pkgs;
610-
inherit (final.buildPackages.pkgs) cacert;
611608
};
612609

613610
# Loads a plan and filters the package directories using cleanSourceWith

0 commit comments

Comments
 (0)