diff --git a/builder/default.nix b/builder/default.nix index b12fd97b32..e7ff9e7f46 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -13,7 +13,7 @@ # # tl;dr: the builder must not re-introduce any reference to the build plan. -{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, nonReinstallablePkgs, hsPkgs, compiler }: +{ pkgs, buildPackages, pkgsBuildBuild, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, nonReinstallablePkgs, hsPkgs, compiler }: let # Builds a single component of a package. @@ -85,7 +85,7 @@ let # Same as haskellPackages.shellFor in nixpkgs. shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix { - inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib buildPackages evalPackages compiler; + inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib pkgsBuildBuild evalPackages compiler; inherit (buildPackages) glibcLocales; }; diff --git a/builder/shell-for.nix b/builder/shell-for.nix index 4e1ac4f4b8..69f8399aac 100644 --- a/builder/shell-for.nix +++ b/builder/shell-for.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, evalPackages, compiler }: +{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler }: { # `packages` function selects packages that will be worked on in the shell itself. # These packages will not be built by `shellFor`, but their @@ -149,7 +149,7 @@ let # inherit (hsPkgs) hoogle; } // ( lib.optionalAttrs (args ? tools && args.tools ? hoogle) { - hoogle = buildPackages.haskell-nix.hackage-tool ( + hoogle = pkgsBuildBuild.haskell-nix.hackage-tool ( haskellLib.versionOrModToMods args.tools.hoogle ++ [{ name = "hoogle"; compiler-nix-name = compiler.nix-name; @@ -168,12 +168,12 @@ in nativeBuildInputs = [ ghcEnv.drv ] ++ nativeBuildInputs ++ mkDrvArgs.nativeBuildInputs or [] - ++ lib.attrValues (buildPackages.haskell-nix.tools' evalPackages compiler.nix-name tools) + ++ lib.attrValues (pkgsBuildBuild.haskell-nix.tools' evalPackages compiler.nix-name tools) # If this shell is a cross compilation shell include # wrapper script for running cabal build with appropriate args. # Includes `--with-compiler` in case the `cabal.project` file has `with-compiler:` in it. ++ lib.optional (ghcEnv.targetPrefix != "") ( - buildPackages.writeShellScriptBin "${ghcEnv.targetPrefix}cabal" '' + pkgsBuildBuild.writeShellScriptBin "${ghcEnv.targetPrefix}cabal" '' exec cabal \ --with-ghc=${ghcEnv.targetPrefix}ghc \ --with-compiler=${ghcEnv.targetPrefix}ghc \ diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index b96d5821f3..3bedfb94ae 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -455,7 +455,7 @@ let ''} EXPOSED_MODULES_${varname name}="$(tr '\n' ' ' <<< "$exposed_modules $reexported_modules")" - DEPS_${varname name}="$(jq -r '.library."build-depends"[]|select(type=="array")[],select(type=="object").then[]' $json_cabal_file | sed 's/^\([A-Za-z0-9-]*\).*$/\1/g' | sort -u | tr '\n' ' ')" + DEPS_${varname name}="$(jq -r '.library."build-depends"[]|select(type=="array")[],select(type=="object" and .if.not.flag != "vendor-filepath").then[]' $json_cabal_file | sed 's/^\([A-Za-z0-9-]*\).*$/\1/g' | sort -u | tr '\n' ' ')" VER_${varname name}="$(jq -r '.version' $json_cabal_file)" PKGS+=" ${name}" LAST_PKG="${name}" diff --git a/test/githash/default.nix b/test/githash/default.nix index 11b2855a67..b5d3f425f6 100644 --- a/test/githash/default.nix +++ b/test/githash/default.nix @@ -15,9 +15,8 @@ let project = haskell-nix.cabalProject' { inherit src; cabalProjectLocal = builtins.readFile ../cabal.project.local; - # When haskell.nix has come from the store (e.g. on hydra) we need to provide - # a suitable mock of the cleaned source with a .git dir. - modules = (optional (!(src ? origSrc && __pathExists (src.origSrc + "/.git"))) { + # Mock the .git dir to avoid rebuilding on every commit. + modules = [{ packages.githash-test.src = rec { origSrc = evalPackages.runCommand "githash-test-src" { nativeBuildInputs = [ evalPackages.gitReallyMinimal ]; } '' @@ -32,7 +31,6 @@ let origSrcSubDir = origSrc + origSubDir; outPath = origSrcSubDir; }; - }) ++ [{ packages.githash-test.components.exes.githash-test.build-tools = mkForce [ git ]; }]; inherit compiler-nix-name evalPackages; diff --git a/test/tests.sh b/test/tests.sh index e7aff800ae..41480f0575 100755 --- a/test/tests.sh +++ b/test/tests.sh @@ -96,11 +96,12 @@ fi if [ "$TESTS" == "multi-target" ] || [ "$TESTS" == "all" ]; then printf "*** Checking that a nix-shell works for a multi-target project...\n" >& 2 + TEST_CABAL_DIR=$(mktemp -d) nix-shell $NIX_BUILD_ARGS \ --pure ./default.nix \ --argstr compiler-nix-name "$GHC" \ -A cabal-simple.test-shell \ - --run 'cd cabal-simple && CABAL_DIR=$(mktemp -d) cabal new-build' + --run "cd cabal-simple && CABAL_DIR=$TEST_CABAL_DIR cabal update && CABAL_DIR=$TEST_CABAL_DIR cabal build" echo >& 2 fi @@ -123,7 +124,7 @@ if [ "$TESTS" == "shellFor-multiple-package" ] || [ "$TESTS" == "all" ]; then --pure ./default.nix \ --argstr compiler-nix-name $SHELL_FOR_GHC \ -A shell-for.envPkga \ - --run 'cd shell-for && CABAL_DIR=$(mktemp -d) cabal new-build --project=single.project all' + --run 'cd shell-for && CABAL_DIR=$(mktemp -d) cabal new-build --project-file=single.project all' echo >& 2 fi