Skip to content

Allow reinstall of filepath in GHC 9.4.8 #2224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
};

Expand Down
8 changes: 4 additions & 4 deletions builder/shell-for.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 2 additions & 4 deletions test/githash/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]; } ''
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions test/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down