Skip to content

Commit 9fe3456

Browse files
Try #1659:
2 parents d68d847 + 2375703 commit 9fe3456

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

overlays/haskell.nix

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,37 +211,38 @@ final: prev: {
211211
# dotCabalName anyway.
212212
dotCabalName = "dot-cabal-" + allNames;
213213
# This is very big, and cheap to build: prefer building it locally
214-
tarballRepos = final.runCommand dotCabalName { nativeBuildInputs = [ cabal-install ]; preferLocalBuild = true; } ''
214+
tarballRepoFor = name: index: final.runCommand "tarballRepo_${name}" {
215+
nativeBuildInputs = [ cabal-install ];
216+
} ''
217+
set -xe
218+
215219
mkdir -p $out/.cabal
216220
cat <<EOF > $out/.cabal/config
217-
${final.lib.concatStrings (
218-
final.lib.mapAttrsToList (name: index:
219-
''
220221
repository ${name}
221222
url: file:${mkLocalHackageRepo { inherit name index; }}
222223
secure: True
223224
root-keys:
224225
key-threshold: 0
225226
226-
'') allTarballs
227-
)}
228227
EOF
229228
230229
# All repositories must be mkdir'ed before calling new-update on any repo,
231230
# otherwise it fails.
232-
${final.lib.concatStrings (map (name: ''
233-
mkdir -p $out/.cabal/packages/${name}
234-
'') (builtins.attrNames allTarballs))}
231+
mkdir -p $out/.cabal/packages/${name}
235232
236-
${final.lib.concatStrings (map (name: ''
237-
HOME=$out cabal new-update ${name}
238-
'') (builtins.attrNames allTarballs))}
233+
HOME=$out cabal new-update ${name}
239234
'';
235+
f = name: index:
236+
let x = tarballRepoFor name index; in
237+
''
238+
ln -s ${x}/.cabal/packages/${name} $out/.cabal/packages/${name}
239+
cat ${x}/.cabal/config >> $out/.cabal/config
240+
'';
240241
in
241242
# Add the extra-hackage-repos where we have all the files needed.
242243
final.runCommand dotCabalName { nativeBuildInputs = [ final.xorg.lndir ]; } ''
243-
mkdir $out
244-
lndir ${tarballRepos} $out
244+
mkdir -p $out/.cabal/packages
245+
${builtins.concatStringsSep "\n" (final.lib.mapAttrsToList f allTarballs)}
245246
246247
${final.lib.concatStrings (final.lib.mapAttrsToList (name: repo: ''
247248
mkdir -p $out/.cabal/packages/${name}

0 commit comments

Comments
 (0)