on iko/ghcjs-patch-master help sign in
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).

commitbc01ebc05a8105035c9449943046b46c8364b932 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateThu 30 May 2019, 17:13 (7 years ago) parentd67fc2d
3 files changed+19−5
default.nix+6−3 lib/cabalProjectToNix.nix+3−1 nix-tools/default.nix+10−1
default.nix+6−3
@@ -117,7 +117,11 @@ let
117117 # Programs for generating Nix expressions from Cabal and Stack
118118 # files. We need to make sure we build this from the buildPackages,
119119 # we never want to actually cross compile nix-tools on it's own.
120− nix-tools = pkgs.buildPackages.callPackage ./nix-tools { inherit fetchExternal cleanSourceHaskell; inherit (self) mkCabalProjectPkgSet; };
120+ nix-tools = pkgs.buildPackages.callPackage ./nix-tools {
121+ inherit fetchExternal cleanSourceHaskell;
122+ inherit (pkgs.buildPackages.haskellPackages) hpack;
123+ inherit (self) mkCabalProjectPkgSet;
124+ };
121125
122126 # Function to call stackToNix
123127 callStackToNix = self.callPackage ./call-stack-to-nix.nix {};
@@ -188,10 +192,9 @@ let
188192 callCabalProjectToNix = import ./lib/cabalProjectToNix.nix {
189193 inherit (self) dotCabal;
190194 inherit pkgs;
191− inherit (pkgs) runCommand cabal-install ghc;
195+ inherit (pkgs) runCommand cabal-install ghc symlinkJoin cacert;
192196 inherit (pkgs.haskellPackages) hpack;
193197 inherit (self) nix-tools;
194− inherit (pkgs) symlinkJoin;
195198 };
196199 });
197200
lib/cabalProjectToNix.nix+3−1
@@ -1,4 +1,4 @@
1−{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin }:
1+{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert }:
22let defaultGhc = ghc;
33 defaultCabalInstall = cabal-install;
44in { index-state, index-sha256 ? (import ./index-state-hashes.nix).${index-state} or null, src, ghc ? defaultGhc, cabal-install ? defaultCabalInstall }:
@@ -29,6 +29,8 @@ let
2929 # without the source available (we cleaneSourceWith'd it),
3030 # this may not produce the right result.
3131 find . -name package.yaml -exec hpack "{}" \;
32+ export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
33+ export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
3234 HOME=${dotCabal { inherit index-state; sha256 = index-sha256; }} cabal new-configure
3335
3436 export LANG=C.utf8 # Needed or stack-to-nix will die on unicode inputs
nix-tools/default.nix+10−1
@@ -1,4 +1,6 @@
1−{ symlinkJoin, fetchExternal, cleanSourceHaskell, mkCabalProjectPkgSet }:
1+{ lib, symlinkJoin, makeWrapper
2+, hpack, git, nix, nix-prefetch-scripts
3+, fetchExternal, cleanSourceHaskell, mkCabalProjectPkgSet }:
24
35let
46 src = cleanSourceHaskell (fetchExternal {
@@ -25,8 +27,15 @@ let
2527
2628 hsPkgs = pkgSet.config.hsPkgs;
2729
30+ tools = [ hpack git nix nix-prefetch-scripts ];
2831in
2932 symlinkJoin {
3033 name = "nix-tools";
3134 paths = builtins.attrValues hsPkgs.nix-tools.components.exes;
35+ buildInputs = [ makeWrapper ];
36+ postBuild = ''
37+ for prog in stack-to-nix cabal-to-nix plan-to-nix; do
38+ wrapProgram "$out/bin/$prog" --prefix PATH : "${lib.makeBinPath tools}"
39+ done
40+ '';
3241 }