on iko/ghcjs-patch-master help sign in
Throw better error when conf files are missing (#1030)

* Throw better error when conf files are missing Previously, if some directories were missing .conf files, an error like this would be thrown: cp: missing destination file operand after '/nix/store/pnmrz06g0sa4s3yx53hgmr9k8jrh6ww0-ouroboros-network-framework-lib-ouroboros-network-framework-0.1.0.0-haddock-config/lib/ghc-8.6.5/package.conf.d' While normally this shouldn't occur, I've seen it happen in CI anyways, with the problem disappearing if the store path that's missing the files was rebuilt a couple times. With this commit, it becomes much easier to figure out which store path is missing the files, which would be very hard to figure out from the previous message.

commitfeea345b321c485b25ef3d46366b22020f2334aa authorSilvan Mosberger <contact@infinisil.com> dateSun 7 Feb 2021, 15:13 (6 years ago) parent59a9ee7
6 files changed+35−19
builder/comp-builder.nix+9−9 builder/make-config-files.nix+14−2 ci.nix+5−1 compiler/ghc/default.nix+4−4 mk-local-hackage-repo/default.nix+1−1 test/index-state/default.nix+2−2
builder/comp-builder.nix+9−9
@@ -371,7 +371,14 @@ let
371371 echo "package-id $id" >> $out/envDep
372372 else
373373 echo 'ERROR: ${package.identifier.name} id could not be found with ${target-pkg-and-db}'
374− exit 0
374+ exit 1
375+ fi
376+ if ver=$(${target-pkg-and-db} field ${package.identifier.name} version --simple-output); then
377+ echo "constraint: ${package.identifier.name} == $ver" >> $out/exactDep/cabal.config
378+ echo "constraint: ${package.identifier.name} installed" >> $out/exactDep/cabal.config
379+ else
380+ echo 'ERROR: ${package.identifier.name} version could not be found with ${target-pkg-and-db}'
381+ exit 1
375382 fi
376383 ''
377384 else
@@ -389,17 +396,10 @@ let
389396 echo "--dependency=${package.identifier.name}:''${name#z-${package.identifier.name}-z-}=$id" >> $out/exactDep/configure-flags
390397 else
391398 echo 'ERROR: ${package.identifier.name} id could not be found with ${target-pkg-and-db}'
392− exit 0
399+ exit 1
393400 fi
394401 '')
395402 }
396− if ver=$(${target-pkg-and-db} field ${package.identifier.name} version --simple-output); then
397− echo "constraint: ${package.identifier.name} == $ver" >> $out/exactDep/cabal.config
398− echo "constraint: ${package.identifier.name} installed" >> $out/exactDep/cabal.config
399− else
400− echo 'ERROR: ${package.identifier.name} version could not be found with ${target-pkg-and-db}'
401− exit 0
402− fi
403403 ''}
404404 ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId) ''
405405 mkdir -p $out/bin
builder/make-config-files.nix+14−2
@@ -93,12 +93,24 @@ let
9393
9494 for l in "${cfgFiles}"; do
9595 if [ -n "$l" ]; then
96− cp -f "$l/${packageCfgDir}/"*.conf $out/${packageCfgDir}
96+ files=("$l/${packageCfgDir}/"*.conf)
97+ if (( ''${#files[@]} )); then
98+ cp -f "''${files[@]}" $out/${packageCfgDir}
99+ else
100+ echo "$l/${packageCfgDir} didn't contain any *.conf files!"
101+ exit 1
102+ fi
97103 fi
98104 done
99105 for l in "${libs}"; do
100106 if [ -n "$l" ]; then
101− cp -f "$l/package.conf.d/"*.conf $out/${packageCfgDir}
107+ files=("$l/package.conf.d/"*.conf)
108+ if (( ''${#files[@]} )); then
109+ cp -f "''${files[@]}" $out/${packageCfgDir}
110+ else
111+ echo "$l/package.conf.d didn't contain any *.conf files!"
112+ exit 1
113+ fi
102114 fi
103115 done
104116
ci.nix+5−1
@@ -25,6 +25,7 @@
2525 # Update supported-ghc-versions.md to reflect any changes made here.
2626 {
2727 ghc865 = true;
28+ ghc884 = false; # Just included because the native version is needed at eval time
2829 } // nixpkgs.lib.optionalAttrs (nixpkgsName == "R2009") {
2930 ghc883 = false;
3031 ghc884 = true;
@@ -51,9 +52,12 @@
5152 || (nixpkgsName == "R2003" && __elem compiler-nix-name ["ghc865"]))) {
5253 # Windows cross compilation is currently broken on macOS
5354 inherit (lib.systems.examples) mingwW64;
54− } // lib.optionalAttrs (system == "x86_64-linux") {
55+ } // lib.optionalAttrs (system == "x86_64-linux"
56+ && !(nixpkgsName == "R2003" && compiler-nix-name == "ghc884")) {
5557 # Musl cross only works on linux
5658 # aarch64 cross only works on linux
59+ # We also skip these for the R2003 was build of ghc884 (we only need the
60+ # native so ifdLevel 1 includes compiler needed in ifdLevel2 eval)
5761 inherit (lib.systems.examples) musl64 aarch64-multiplatform;
5862 };
5963 isDisabled = d:
compiler/ghc/default.nix+4−4
@@ -285,19 +285,19 @@ stdenv.mkDerivation (rec {
285285 # Sanity checks for https://github.com/input-output-hk/haskell.nix/issues/660
286286 if ! "$out/bin/${targetPrefix}ghc" --version; then
287287 echo "ERROR: Missing file $out/bin/${targetPrefix}ghc"
288− exit 0
288+ exit 1
289289 fi
290290 if ! "$out/bin/${targetPrefix}ghc-pkg" --version; then
291291 echo "ERROR: Missing file $out/bin/${targetPrefix}ghc-pkg"
292− exit 0
292+ exit 1
293293 fi
294294 if [[ ! -d "$out/lib/${targetPrefix}ghc-${version}" ]]; then
295295 echo "ERROR: Missing directory $out/lib/${targetPrefix}ghc-${version}"
296− exit 0
296+ exit 1
297297 fi
298298 if (( $(ls -1 "$out/lib/${targetPrefix}ghc-${version}" | wc -l) < 30 )); then
299299 echo "ERROR: Expected more files in $out/lib/${targetPrefix}ghc-${version}"
300− exit 0
300+ exit 1
301301 fi
302302 '';
303303
mk-local-hackage-repo/default.nix+1−1
@@ -31,7 +31,7 @@ ${
3131 pkgs.lib.optionalString (index ? outputHash) ''
3232 if [[ "${index.outputHash}" != "$index_sha256" ]]; then
3333 echo "ERROR See https://github.com/input-output-hk/haskell.nix/issues/884"
34− exit 0
34+ exit 1
3535 fi
3636''}
3737export index_length=$(stat --printf="%s" ${index})
test/index-state/default.nix+2−2
@@ -26,11 +26,11 @@ in
2626 buildCommand = ''
2727 if [[ "${version-before}" != "0.6.0.0" ]]; then
2828 echo 'Unexpected version ${version-before} (expected "0.6.0.0")'
29− exit 0
29+ exit 1
3030 fi
3131 if [[ "${version-after}" != "0.6.0.1" ]]; then
3232 echo 'Unexpected version ${version-after} (expected "0.6.0.1")'
33− exit 0
33+ exit 1
3434 fi
3535
3636 touch $out