summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-12-14 08:14:12 -0500
committerBen Sima <ben@bsima.me>2021-12-14 08:17:46 -0500
commit58d00038a26efad6f103f020410d11f9c114899d (patch)
treead82924da4bd5c1bcf8c492a8a427a0cb4bed757
parentddd8ca76de7fb32f2253986e425f161c11472cf0 (diff)
Add custom package db to ghcPkgFindModule
This means my call to ghc-pkg will look at the full package set from Hoogle.
-rw-r--r--Biz/Bild.hs8
-rw-r--r--Biz/Bild.nix24
-rw-r--r--Biz/Bild/Deps/Haskell.nix4
3 files changed, 21 insertions, 15 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs
index 17fb883..4d7fadd 100644
--- a/Biz/Bild.hs
+++ b/Biz/Bild.hs
@@ -413,13 +413,11 @@ analyze path = do
}
ghcPkgFindModule :: Set String -> String -> IO (Set String)
-ghcPkgFindModule acc m =
+ghcPkgFindModule acc m = do
+ packageDb <- Env.getEnv "GHC_PACKAGE_PATH"
Process.readProcess
"ghc-pkg"
- -- instead of relying on global deps declared in ./Bild/Deps/Haskell.nix, I
- -- could fetch a global package-db from hackage API and pass it here with
- -- --package-db=FILE
- ["--names-only", "--simple-output", "find-module", m]
+ ["--package-db", packageDb, "--names-only", "--simple-output", "find-module", m]
""
/> String.lines
/> Set.fromList
diff --git a/Biz/Bild.nix b/Biz/Bild.nix
index 8d57d54..6279d2f 100644
--- a/Biz/Bild.nix
+++ b/Biz/Bild.nix
@@ -22,6 +22,12 @@ let
#mkGhcjsPackageSet = nixpkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages;
ghcPackageSetFull = mkGhcPackageSet haskellDeps;
+ ghcPackageSetBild = mkGhcPackageSet (hpkgs: with hpkgs; [
+ aeson async base bytestring conduit conduit-extra containers directory
+ docopt filepath process protolude rainbow regex-applicative split tasty
+ tasty-hunit tasty-quickcheck text
+ wai # can remove when removed from Biz.Log
+ ]);
in rec {
inherit (nixpkgs) lib stdenv pkgs sources;
@@ -30,11 +36,14 @@ in rec {
bild = stdenv.mkDerivation {
name = "bild";
src = ../.;
- nativeBuildInputs = [ ghcPackageSetFull ];
+ nativeBuildInputs = [ ghcPackageSetBild ];
buildInputs = [ nixpkgs.makeWrapper ];
strictDeps = true;
buildPhase = ''
- mkdir -p $out/bin
+ mkdir -p $out/bin $out/lib/ghc-${ghcPackageSetFull.version}
+ cp -r \
+ ${ghcPackageSetFull}/lib/ghc-${ghcPackageSetFull.version}/package.conf.d \
+ $out/lib/ghc-${ghcPackageSetFull.version}
ghc \
-Werror \
-i. \
@@ -43,7 +52,10 @@ in rec {
-o $out/bin/bild
'';
installPhase = ''
- wrapProgram $out/bin/bild --prefix PATH : ${lib.makeBinPath [ ghcPackageSetFull ]}
+ wrapProgram $out/bin/bild \
+ --prefix PATH : ${lib.makeBinPath [ ghcPackageSetBild ]} \
+ --set GHC_PACKAGE_PATH \
+ $out/lib/ghc-${ghcPackageSetFull.version}/package.conf.d
'';
};
@@ -59,11 +71,9 @@ in rec {
# working directory:
MAIN = "." + lib.strings.removePrefix (toString src) (toString main);
buildPhase = ''
- set -eux
mkdir $out
- : analyzing with bild
- ${bild}/bin/bild --json "$MAIN" 1> $out/analysis.json 2> $out/stderr
- set +eux
+ ${bild}/bin/bild --json "$MAIN" 1> $out/analysis.json \
+ 2> >(tee -a $out/stderr >&2)
'';
installPhase = "exit 0";
};
diff --git a/Biz/Bild/Deps/Haskell.nix b/Biz/Bild/Deps/Haskell.nix
index bbc8ac4..39139af 100644
--- a/Biz/Bild/Deps/Haskell.nix
+++ b/Biz/Bild/Deps/Haskell.nix
@@ -1,8 +1,6 @@
hpkgs:
-# This is the global set of Haskell packages which gets deployed to Hoogle, and
-# is used to create the global 'nix-shell' environment. Eventually, bild should
-# create the environment for me.
+# This is the global set of Haskell packages which gets deployed to Hoogle.
with hpkgs;
[