Skip to content

Throw better error when conf files are missing #1030

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 14 commits into from
Feb 7, 2021
18 changes: 9 additions & 9 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,14 @@ let
echo "package-id $id" >> $out/envDep
else
echo 'ERROR: ${package.identifier.name} id could not be found with ${target-pkg-and-db}'
exit 0
exit 1
fi
if ver=$(${target-pkg-and-db} field ${package.identifier.name} version --simple-output); then
echo "constraint: ${package.identifier.name} == $ver" >> $out/exactDep/cabal.config
echo "constraint: ${package.identifier.name} installed" >> $out/exactDep/cabal.config
else
echo 'ERROR: ${package.identifier.name} version could not be found with ${target-pkg-and-db}'
exit 1
fi
''
else
Expand All @@ -389,17 +396,10 @@ let
echo "--dependency=${package.identifier.name}:''${name#z-${package.identifier.name}-z-}=$id" >> $out/exactDep/configure-flags
else
echo 'ERROR: ${package.identifier.name} id could not be found with ${target-pkg-and-db}'
exit 0
exit 1
fi
'')
}
if ver=$(${target-pkg-and-db} field ${package.identifier.name} version --simple-output); then
echo "constraint: ${package.identifier.name} == $ver" >> $out/exactDep/cabal.config
echo "constraint: ${package.identifier.name} installed" >> $out/exactDep/cabal.config
else
echo 'ERROR: ${package.identifier.name} version could not be found with ${target-pkg-and-db}'
exit 0
fi
''}
${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId) ''
mkdir -p $out/bin
Expand Down
16 changes: 14 additions & 2 deletions builder/make-config-files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,24 @@ let

for l in "${cfgFiles}"; do
if [ -n "$l" ]; then
cp -f "$l/${packageCfgDir}/"*.conf $out/${packageCfgDir}
files=("$l/${packageCfgDir}/"*.conf)
if (( ''${#files[@]} )); then
cp -f "''${files[@]}" $out/${packageCfgDir}
else
echo "$l/${packageCfgDir} didn't contain any *.conf files!"
exit 1
fi
fi
done
for l in "${libs}"; do
if [ -n "$l" ]; then
cp -f "$l/package.conf.d/"*.conf $out/${packageCfgDir}
files=("$l/package.conf.d/"*.conf)
if (( ''${#files[@]} )); then
cp -f "''${files[@]}" $out/${packageCfgDir}
else
echo "$l/package.conf.d didn't contain any *.conf files!"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no exit 1 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, must've missed that

exit 1
fi
fi
done

Expand Down
6 changes: 5 additions & 1 deletion ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# Update supported-ghc-versions.md to reflect any changes made here.
{
ghc865 = true;
ghc884 = false; # Just included because the native version is needed at eval time
} // nixpkgs.lib.optionalAttrs (nixpkgsName == "R2009") {
ghc883 = false;
ghc884 = true;
Expand All @@ -51,9 +52,12 @@
|| (nixpkgsName == "R2003" && __elem compiler-nix-name ["ghc865"]))) {
# Windows cross compilation is currently broken on macOS
inherit (lib.systems.examples) mingwW64;
} // lib.optionalAttrs (system == "x86_64-linux") {
} // lib.optionalAttrs (system == "x86_64-linux"
&& !(nixpkgsName == "R2003" && compiler-nix-name == "ghc884")) {
# Musl cross only works on linux
# aarch64 cross only works on linux
# We also skip these for the R2003 was build of ghc884 (we only need the
# native so ifdLevel 1 includes compiler needed in ifdLevel2 eval)
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
};
isDisabled = d:
Expand Down
8 changes: 4 additions & 4 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,19 @@ stdenv.mkDerivation (rec {
# Sanity checks for https://github.com/input-output-hk/haskell.nix/issues/660
if ! "$out/bin/${targetPrefix}ghc" --version; then
echo "ERROR: Missing file $out/bin/${targetPrefix}ghc"
exit 0
exit 1
fi
if ! "$out/bin/${targetPrefix}ghc-pkg" --version; then
echo "ERROR: Missing file $out/bin/${targetPrefix}ghc-pkg"
exit 0
exit 1
fi
if [[ ! -d "$out/lib/${targetPrefix}ghc-${version}" ]]; then
echo "ERROR: Missing directory $out/lib/${targetPrefix}ghc-${version}"
exit 0
exit 1
fi
if (( $(ls -1 "$out/lib/${targetPrefix}ghc-${version}" | wc -l) < 30 )); then
echo "ERROR: Expected more files in $out/lib/${targetPrefix}ghc-${version}"
exit 0
exit 1
fi
'';

Expand Down
2 changes: 1 addition & 1 deletion mk-local-hackage-repo/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ${
pkgs.lib.optionalString (index ? outputHash) ''
if [[ "${index.outputHash}" != "$index_sha256" ]]; then
echo "ERROR See https://github.com/input-output-hk/haskell.nix/issues/884"
exit 0
exit 1
fi
''}
export index_length=$(stat --printf="%s" ${index})
Expand Down
4 changes: 2 additions & 2 deletions test/index-state/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ in
buildCommand = ''
if [[ "${version-before}" != "0.6.0.0" ]]; then
echo 'Unexpected version ${version-before} (expected "0.6.0.0")'
exit 0
exit 1
fi
if [[ "${version-after}" != "0.6.0.1" ]]; then
echo 'Unexpected version ${version-after} (expected "0.6.0.1")'
exit 0
exit 1
fi

touch $out
Expand Down