Skip to content

Commit 3461d04

Browse files
committed
Add cabal-issue-8352-workaround
See haskell/cabal#8352
1 parent 25b47bf commit 3461d04

File tree

4 files changed

+54
-51
lines changed

4 files changed

+54
-51
lines changed

build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ in rec {
4949
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
5050
nix-tools = haskell.internal-nix-tools;
5151
cabal-install = haskell.internal-cabal-install;
52-
inherit (haskell) update-index-state-hashes;
52+
inherit (haskell) update-index-state-hashes cabal-issue-8352-workaround;
5353
};
5454
update-stackage = haskell.callPackage ./scripts/update-stackage.nix {
5555
inherit (pkgs) stdenv lib writeScript coreutils glibc git

lib/cabal-project-parser.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let
145145
repoContents = if inputMap ? ${attrs.url}
146146
# If there is an input use it to make `file:` url and create a suitable `.cabal/packages/${name}` directory
147147
then evalPackages.runCommand name ({
148-
nativeBuildInputs = [ cabal-install ];
148+
nativeBuildInputs = [ cabal-install ] ++ evalPackages.haskell-nix.cabal-issue-8352-workaround;
149149
preferLocalBuild = true;
150150
}) ''
151151
HOME=$(mktemp -d)
@@ -162,7 +162,7 @@ let
162162
cp -r $HOME/.cabal/packages/${name} $out
163163
''
164164
else evalPackages.runCommand name ({
165-
nativeBuildInputs = [ cabal-install evalPackages.curl nix-tools ];
165+
nativeBuildInputs = [ cabal-install evalPackages.curl nix-tools ] ++ evalPackages.haskell-nix.cabal-issue-8352-workaround;
166166
LOCALE_ARCHIVE = pkgs.lib.optionalString (evalPackages.stdenv.buildPlatform.libc == "glibc") "${evalPackages.glibcLocales}/lib/locale/locale-archive";
167167
LANG = "en_US.UTF-8";
168168
preferLocalBuild = true;

overlays/haskell.nix

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -205,61 +205,64 @@ final: prev: {
205205
# Creates Cabal local repository from { name, index } set.
206206
mkLocalHackageRepo = import ../mk-local-hackage-repo final;
207207

208+
# Dummy version of ghc to work around https://github.com/haskell/cabal/issues/8352
209+
cabal-issue-8352-workaround = [
210+
(final.writeTextFile {
211+
name = "dummy-ghc";
212+
executable = true;
213+
destination = "/bin/ghc";
214+
text = ''
215+
#!${final.runtimeShell}
216+
case "$*" in
217+
--version*)
218+
echo 'The Glorious Glasgow Haskell Compilation System, version 8.10.7'
219+
;;
220+
--numeric-version*)
221+
echo '8.10.7'
222+
;;
223+
--supported-languages*)
224+
echo Haskell2010
225+
;;
226+
--info*)
227+
echo '[]'
228+
;;
229+
*)
230+
echo "Unknown argument '$*'" >&2
231+
exit 1
232+
;;
233+
esac
234+
exit 0
235+
'';
236+
})
237+
(final.writeTextFile {
238+
name = "dummy-ghc";
239+
executable = true;
240+
destination = "/bin/ghc-pkg";
241+
text = ''
242+
#!${final.runtimeShell}
243+
case "$*" in
244+
--version*)
245+
echo 'GHC package manager version 8.10.7'
246+
;;
247+
*)
248+
echo "Unknown argument '$*'" >&2
249+
exit 1
250+
;;
251+
esac
252+
exit 0
253+
'';
254+
})
255+
];
256+
208257
dotCabal = { index-state, sha256, cabal-install, extra-hackage-tarballs ? {}, extra-hackage-repos ? {}, ... }@args:
209258
let
210259
allTarballs = hackageTarball args // extra-hackage-tarballs;
211260
allNames = final.lib.concatStringsSep "-" (builtins.attrNames allTarballs);
212261
# Main Hackage index-state is embedded in its name and thus will propagate to
213262
# dotCabalName anyway.
214263
dotCabalName = "dot-cabal-" + allNames;
215-
# Dummy version of ghc to work around https://github.com/haskell/cabal/issues/8352
216-
dummy-ghc = final.writeTextFile {
217-
name = "dummy-ghc";
218-
executable = true;
219-
destination = "/bin/ghc";
220-
text = ''
221-
#!${final.runtimeShell}
222-
case "$*" in
223-
--version*)
224-
echo 'The Glorious Glasgow Haskell Compilation System, version 8.10.7'
225-
;;
226-
--numeric-version*)
227-
echo '8.10.7'
228-
;;
229-
--supported-languages*)
230-
echo Haskell2010
231-
;;
232-
--info*)
233-
echo '[]'
234-
;;
235-
*)
236-
echo "Unknown argument '$*'" >&2
237-
exit 1
238-
;;
239-
esac
240-
exit 0
241-
'';
242-
};
243-
dummy-ghc-pkg = final.writeTextFile {
244-
name = "dummy-ghc";
245-
executable = true;
246-
destination = "/bin/ghc-pkg";
247-
text = ''
248-
#!${final.runtimeShell}
249-
case "$*" in
250-
--version*)
251-
echo 'GHC package manager version 8.10.7'
252-
;;
253-
*)
254-
echo "Unknown argument '$*'" >&2
255-
exit 1
256-
;;
257-
esac
258-
exit 0
259-
'';
260-
};
261264
tarballRepoFor = name: index: final.runCommand "tarballRepo_${name}" {
262-
nativeBuildInputs = [ cabal-install dummy-ghc dummy-ghc-pkg ];
265+
nativeBuildInputs = [ cabal-install cabal-issue-8352-workaround ];
263266
} ''
264267
set -xe
265268

scripts/update-hackage.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ stdenv, lib, writeScript, coreutils, glibc, git, openssh
22
, nix-tools, cabal-install, nixFlakes
33
, gawk, bash, curl, findutils
4-
, update-index-state-hashes }@args:
4+
, update-index-state-hashes, cabal-issue-8352-workaround }@args:
55

66
import ./update-external.nix
77
(removeAttrs args ["update-index-state-hashes"]) {

0 commit comments

Comments
 (0)