Fix callCabalProjectToNix plans with source repos (#149)

* Fix callCabalProjectToNix plans with source repos

* nix-tools: wrap executables to provide dependencies

* cabalProjectToNix needs git for cabal source repos

When resolving source repos the `cabal` executable uses `git` from
the `PATH` (not using nix store reference).
This commit is contained in:
Hamish Mackenzie 2019-05-30 17:13:18 +12:00 committed by Moritz Angermann
parent d67fc2db76
commit bc01ebc05a
3 changed files with 19 additions and 5 deletions

View File

@ -117,7 +117,11 @@ let
# Programs for generating Nix expressions from Cabal and Stack
# files. We need to make sure we build this from the buildPackages,
# we never want to actually cross compile nix-tools on it's own.
nix-tools = pkgs.buildPackages.callPackage ./nix-tools { inherit fetchExternal cleanSourceHaskell; inherit (self) mkCabalProjectPkgSet; };
nix-tools = pkgs.buildPackages.callPackage ./nix-tools {
inherit fetchExternal cleanSourceHaskell;
inherit (pkgs.buildPackages.haskellPackages) hpack;
inherit (self) mkCabalProjectPkgSet;
};
# Function to call stackToNix
callStackToNix = self.callPackage ./call-stack-to-nix.nix {};
@ -188,10 +192,9 @@ let
callCabalProjectToNix = import ./lib/cabalProjectToNix.nix {
inherit (self) dotCabal;
inherit pkgs;
inherit (pkgs) runCommand cabal-install ghc;
inherit (pkgs) runCommand cabal-install ghc symlinkJoin cacert;
inherit (pkgs.haskellPackages) hpack;
inherit (self) nix-tools;
inherit (pkgs) symlinkJoin;
};
});

View File

@ -1,4 +1,4 @@
{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin }:
{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert }:
let defaultGhc = ghc;
defaultCabalInstall = cabal-install;
in { index-state, index-sha256 ? (import ./index-state-hashes.nix).${index-state} or null, src, ghc ? defaultGhc, cabal-install ? defaultCabalInstall }:
@ -29,6 +29,8 @@ let
# without the source available (we cleaneSourceWith'd it),
# this may not produce the right result.
find . -name package.yaml -exec hpack "{}" \;
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
HOME=${dotCabal { inherit index-state; sha256 = index-sha256; }} cabal new-configure
export LANG=C.utf8 # Needed or stack-to-nix will die on unicode inputs

View File

@ -1,4 +1,6 @@
{ symlinkJoin, fetchExternal, cleanSourceHaskell, mkCabalProjectPkgSet }:
{ lib, symlinkJoin, makeWrapper
, hpack, git, nix, nix-prefetch-scripts
, fetchExternal, cleanSourceHaskell, mkCabalProjectPkgSet }:
let
src = cleanSourceHaskell (fetchExternal {
@ -25,8 +27,15 @@ let
hsPkgs = pkgSet.config.hsPkgs;
tools = [ hpack git nix nix-prefetch-scripts ];
in
symlinkJoin {
name = "nix-tools";
paths = builtins.attrValues hsPkgs.nix-tools.components.exes;
buildInputs = [ makeWrapper ];
postBuild = ''
for prog in stack-to-nix cabal-to-nix plan-to-nix; do
wrapProgram "$out/bin/$prog" --prefix PATH : "${lib.makeBinPath tools}"
done
'';
}