diff --git a/overlays/haskell.nix b/overlays/haskell.nix index 4bf3f29277..3912ca898b 100644 --- a/overlays/haskell.nix +++ b/overlays/haskell.nix @@ -257,37 +257,38 @@ final: prev: { ''; }; # This is very big, and cheap to build: prefer building it locally - tarballRepos = final.runCommand dotCabalName { nativeBuildInputs = [ cabal-install dummy-ghc dummy-ghc-pkg ]; preferLocalBuild = true; } '' + tarballRepoFor = name: index: final.runCommand "tarballRepo_${name}" { + nativeBuildInputs = [ cabal-install dummy-ghc dummy-ghc-pkg ]; + } '' + set -xe + mkdir -p $out/.cabal cat < $out/.cabal/config - ${final.lib.concatStrings ( - final.lib.mapAttrsToList (name: index: - '' repository ${name} url: file:${mkLocalHackageRepo { inherit name index; }} secure: True root-keys: key-threshold: 0 - '') allTarballs - )} EOF # All repositories must be mkdir'ed before calling new-update on any repo, # otherwise it fails. - ${final.lib.concatStrings (map (name: '' - mkdir -p $out/.cabal/packages/${name} - '') (builtins.attrNames allTarballs))} + mkdir -p $out/.cabal/packages/${name} - ${final.lib.concatStrings (map (name: '' - HOME=$out cabal new-update ${name} - '') (builtins.attrNames allTarballs))} + HOME=$out cabal new-update ${name} ''; + f = name: index: + let x = tarballRepoFor name index; in + '' + ln -s ${x}/.cabal/packages/${name} $out/.cabal/packages/${name} + cat ${x}/.cabal/config >> $out/.cabal/config + ''; in # Add the extra-hackage-repos where we have all the files needed. final.runCommand dotCabalName { nativeBuildInputs = [ final.xorg.lndir ]; } '' - mkdir $out - lndir ${tarballRepos} $out + mkdir -p $out/.cabal/packages + ${builtins.concatStringsSep "\n" (final.lib.mapAttrsToList f allTarballs)} ${final.lib.concatStrings (final.lib.mapAttrsToList (name: repo: '' mkdir -p $out/.cabal/packages/${name}