on iko/ghcjs-patch-master help sign in
Replace collectRunComponents with haskellLib.check (#316)

This change replaces `passthru.run` and `collectRunComponents` with `haskellLib.check` and `$pkg.checks`. Uses `ln -s` instead of `cp` for DLLs to avoid duplicating them. Adds features to help debugging eval issues with haskell.nix/release.nix. The ifdInputLevel can be set to limit the jobs included to control how much work is done at the eval stage when looking for issues. Reduce CI times by excluding older ghc versions from haskellNixRoots (GHC 8.6.3 and 8.6.4) Sets `preferLocalBuild=false` on `callCabalProjectToNix` and `callStackToNix` to ensure they are cached on hydra for both Linux and macOS. Fix `data-dir:` when cleaning components. `normalizeRelativeDir` adds a slash on to the end of `dataDir`. Adding another one here results in `//` and files are left out by mistake.

commita9b01221dd8e23117c9d401a8bb7c3c76ff42d0b authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateFri 29 Nov 2019, 23:28 (7 years ago) parentfa9a60d
33 files changed+241−128
.buildkite/pipeline.yml+4−1 build.nix+22−20 builder/comp-builder.nix+16−30 builder/hspkg-builder.nix+4−1 docs/reference/library.md+17−1 lib/call-cabal-project-to-nix.nix+2−1 lib/call-stack-to-nix.nix+1 lib/check.nix+42 lib/default.nix+6−1 modules/plan.nix+1−1 overlays/bootstrap.nix+3−3 overlays/haskell.nix+30−21 package-set.nix+1−1 release.nix+2 scripts/check-hydra.nix+2−1 test/buildable/default.nix+4−2 test/cabal-22/default.nix+6−4 test/cabal-simple-prof/default.nix+3−1 test/cabal-simple/default.nix+4−2 test/cabal-source-repo/default.nix+5−3 test/cabal-sublib/default.nix+4−2 test/call-cabal-project-to-nix/default.nix+5−3 test/call-stack-to-nix/default.nix+5−3 test/default.nix+11−2 test/exe-only/default.nix+5−3 test/fully-static/default.nix+4−2 test/ghc-options/cabal.nix+5−3 test/ghc-options/stack.nix+5−3 test/project-flags/cabal.nix+5−3 test/project-flags/stack.nix+5−3 test/setup-deps/default.nix+4−2 test/shell-for-setup-deps/default.nix+4−2 test/stack-simple/default.nix+4−3
.buildkite/pipeline.yml+4−1
@@ -7,7 +7,10 @@ steps:
77 - label: 'Check that jobset will evaluate in Hydra'
88 command:
99 - nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
10− - ./check-hydra.sh
10+ - ./check-hydra.sh 0
11+ - ./check-hydra.sh 1
12+ - ./check-hydra.sh 2
13+ - ./check-hydra.sh 3
1114 agents:
1215 system: x86_64-linux
1316
build.nix+22−20
@@ -9,27 +9,19 @@
99, crossSystem ? null
1010, config ? {}
1111, nixpkgsArgs ? { inherit system crossSystem; }
12+, ifdLevel ? 1000
1213}:
1314
1415let
1516 haskellNixArgs = import ./default.nix;
1617 pkgs = import nixpkgs ({
17− config = haskellNixArgs.config // config;
18− overlays = haskellNixArgs.overlays ++
19− [(self: super: {
20− darcs = (self.haskell-nix.hackage-package {
21− name = "darcs";
22− version = "2.14.2";
23− index-state = "2019-10-28T00:00:00Z";
24− plan-sha256 = "1h8dxib0wz6mg8md6ldwa54dsr1dn7vxfij8cfhdawl4y3wr51k0";
25− # Apply the latest darcs.net Setup.hs patches
26− modules = [{packages.darcs.patches = [ ./patches/darcs-setup.patch ];}];
27− }).components.exes.darcs;
28− })]; } // nixpkgsArgs);
18+ config = haskellNixArgs.config // config;
19+ inherit (haskellNixArgs) overlays;
20+ } // nixpkgsArgs);
2921 haskell = pkgs.haskell-nix;
3022
3123in rec {
32− tests = import ./test/default.nix { inherit nixpkgs nixpkgsArgs; };
24+ tests = import ./test/default.nix { inherit nixpkgs nixpkgsArgs ifdLevel; };
3325
3426 # Scripts for keeping Hackage and Stackage up to date, and CI tasks.
3527 # The dontRecurseIntoAttrs prevents these from building on hydra
@@ -52,6 +44,11 @@ in rec {
5244 }) {};
5345 };
5446 };
47+ # Because this is going to be used to test caching on hydra, it must not
48+ # use the darcs package from the haskell.nix we are testing. For that reason
49+ # it uses `pkgs.buildPackages.callPackage` not `haskell.callPackage`
50+ # (We could pull in darcs from a known good haskell.nix for hydra to
51+ # use)
5552 check-hydra = pkgs.buildPackages.callPackage ./scripts/check-hydra.nix {};
5653 check-closure-size = pkgs.buildPackages.callPackage ./scripts/check-closure-size.nix {
5754 inherit (haskell) nix-tools;
@@ -60,11 +57,16 @@ in rec {
6057
6158 # These are pure parts of maintainer-script so they can be built by hydra
6259 # and added to the cache to speed up buildkite.
63− maintainer-script-cache = pkgs.recurseIntoAttrs {
64− inherit (maintainer-scripts) update-docs check-hydra check-closure-size;
65− # Some of the dependencies of the impure scripts so that they will
66− # will be in the cache too for buildkite.
67− inherit (pkgs.buildPackages) glibc coreutils git openssh cabal-install nix-prefetch-git;
68− inherit (haskell) nix-tools;
69− };
60+ maintainer-script-cache = pkgs.recurseIntoAttrs (
61+ (pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isWindows {
62+ inherit (maintainer-scripts) check-hydra;
63+ })
64+ // (pkgs.lib.optionalAttrs (ifdLevel > 2) {
65+ inherit (maintainer-scripts) update-docs check-closure-size;
66+ # Some of the dependencies of the impure scripts so that they will
67+ # will be in the cache too for buildkite.
68+ inherit (pkgs.buildPackages) glibc coreutils git openssh cabal-install nix-prefetch-git;
69+ inherit (haskell) nix-tools;
70+ })
71+ );
7072}
builder/comp-builder.nix+16−30
@@ -20,8 +20,6 @@
2020, preHaddock ? component.preHaddock , postHaddock ? component.postHaddock
2121, shellHook ? ""
2222
23−, doCheck ? component.doCheck || haskellLib.isTest componentId
24−, doCrossCheck ? component.doCrossCheck || false
2523, dontPatchELF ? true
2624, dontStrip ? true
2725
@@ -128,13 +126,7 @@ let
128126
129127 exeExt = lib.optionalString stdenv.hostPlatform.isWindows ".exe";
130128 testExecutable = "dist/build/${componentId.cname}/${componentId.cname}${exeExt}";
131− # exe components are in /bin, but test and benchmarks are not. Perhaps to avoid
132− # them being from being added to the PATH when the all component added to an env.
133− # TODO revist this to find out why and document or maybe change this.
134− installedExeDir = if haskellLib.isTest componentId || haskellLib.isBenchmark componentId
135− then name
136− else "bin";
137− installedExe = "${installedExeDir}/${componentId.cname}${exeExt}";
129+ installedExe = "bin/${componentId.cname}${exeExt}";
138130
139131in stdenv.lib.fix (drv:
140132
@@ -143,20 +135,20 @@ stdenv.mkDerivation ({
143135
144136 src = cleanSrc;
145137
146− inherit doCheck doCrossCheck dontPatchELF dontStrip;
138+ doCheck = false;
139+ doCrossCheck = false;
140+
141+ inherit dontPatchELF dontStrip;
147142
148143 passthru = {
149144 inherit (package) identifier;
150145 config = component;
151− inherit configFiles executableToolDepends cleanSrc;
146+ inherit configFiles executableToolDepends cleanSrc installedExe;
152147 env = shellWrappers;
153148
154149 # The directory containing the haddock documentation.
155150 # `null' if no haddock documentation was built.
156151 haddockDir = if doHaddock' then "${docdir drv.doc}/html" else null;
157− run = runCommand (fullName + "-run") {} ''
158− ${toString component.testWrapper} ${drv}/${installedExe} | tee $out
159− '';
160152 };
161153
162154 meta = {
@@ -217,13 +209,7 @@ stdenv.mkDerivation ({
217209 runHook postBuild
218210 '';
219211
220− checkPhase = ''
221− runHook preCheck
222−
223− ${toString component.testWrapper} ${testExecutable} ${lib.concatStringsSep " " component.testFlags}
224−
225− runHook postCheck
226− '';
212+ checkPhase = "notice: Tests are only executed by building the .run sub-derivation of this component.";
227213
228214 haddockPhase = ''
229215 runHook preHaddock
@@ -281,25 +267,25 @@ stdenv.mkDerivation ({
281267 fi
282268 ''}
283269 ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
284− mkdir -p $out/${name}
270+ mkdir -p $out/bin
285271 if [ -f ${testExecutable} ]; then
286− cp ${testExecutable} $out/${name}/
272+ cp ${testExecutable} $out/bin/
287273 fi
288274 '')
289275 # In case `setup copy` did not creat this
290276 + (lib.optionalString enableSeparateDataOutput "mkdir -p $data")
291277 + (lib.optionalString (stdenv.hostPlatform.isWindows && (haskellLib.mayHaveExecutable componentId)) ''
292− echo "Copying libffi and gmp .dlls ..."
278+ echo "Symlink libffi and gmp .dlls ..."
293279 for p in ${lib.concatStringsSep " " [ libffi gmp ]}; do
294− find "$p" -iname '*.dll' -exec cp {} $out/${installedExeDir} \;
280+ find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
295281 done
296− # copy all .dlls into the local directory.
282+ # symlink all .dlls into the local directory.
297283 # we ask ghc-pkg for *all* dynamic-library-dirs and then iterate over the unique set
298− # to copy over dlls as needed.
299− echo "Copying library dependencies..."
284+ # to symlink over dlls as needed.
285+ echo "Symlink library dependencies..."
300286 for libdir in $(x86_64-pc-mingw32-ghc-pkg --package-db=$packageConfDir field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
301287 if [ -d "$libdir" ]; then
302− find "$libdir" -iname '*.dll' -exec cp {} $out/${installedExeDir} \;
288+ find "$libdir" -iname '*.dll' -exec ln -s {} $out/bin \;
303289 fi
304290 done
305291 '')
@@ -316,7 +302,7 @@ stdenv.mkDerivation ({
316302// lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; inherit revision; } else p) patches; }
317303// haskellLib.optionalHooks {
318304 inherit preUnpack postUnpack preConfigure postConfigure
319− preBuild postBuild preCheck postCheck
305+ preBuild postBuild
320306 preInstall postInstall preHaddock postHaddock;
321307}
322308// lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc"){ LOCALE_ARCHIVE = "${buildPackages.glibcLocales}/lib/locale/locale-archive"; }
builder/hspkg-builder.nix+4−1
@@ -57,8 +57,11 @@ let
5757 ;
5858 };
5959
60−in {
60+in rec {
6161 components = haskellLib.applyComponents buildComp config;
62+ checks = pkgs.recurseIntoAttrs (builtins.mapAttrs
63+ (_: d: haskellLib.check d)
64+ (lib.filterAttrs (_: d: d.config.doCheck) components.tests));
6265 inherit (package) identifier detailLevel isLocal;
6366 inherit setup cabalFile;
6467 isHaskell = true;
docs/reference/library.md+17−1
@@ -286,7 +286,8 @@ Infrastructure.
286286Extracts a selection of components from a Haskell [package set](#package-set).
287287
288288This can be used to filter out all test suites or benchmarks of
289−your project, so that they can be built in Hydra.
289+your project, so that they can be built in Hydra (see check if you
290+waht to run the tests as well as build them).
290291
291292```
292293collectComponents =
@@ -311,6 +312,21 @@ tests = collectComponents "tests" (package: package.identifier.name == "mypackag
311312Will result in moving derivations from `hsPkgs.mypackage.components.tests.unit-tests`
312313to `tests.mypackage.unit-tests`.
313314
315+#### check
316+
317+This function turns a derivation that builds a test into one to run it.
318+
319+| Argument | Type | Description |
320+|-------------------|--------|---------------------|
321+| `drv` | Derivation | One of `$pkg.components.tests.$test`. |
322+
323+For convenience `$pkg.components.tests` are mapped with this function
324+to `$pkg.components.checks`.
325+
326+This function is intended for use with `tests` but it should also work
327+for `exes` and `benchmarks` if you just want to run them to make sure
328+they execute.
329+
314330#### subComponentTypes
315331
316332Sub-component types identify [components](#component) and are one of:
lib/call-cabal-project-to-nix.nix+2−1
@@ -156,10 +156,11 @@ let
156156 }
157157 else replaceSoureRepos rawCabalProject;
158158
159− plan-nix = runCommand "plan-to-nix-pkgs" ({
159+ plan-nix = runCommand (if name == null then "plan-to-nix-pkgs" else name + "-plan-to-nix-pkgs") ({
160160 nativeBuildInputs = [ nix-tools ghc hpack cabal-install pkgs.rsync pkgs.git ];
161161 # Needed or stack-to-nix will die on unicode inputs
162162 LANG = "en_US.UTF-8";
163+ preferLocalBuild = false;
163164 } // (if plan-sha256 == null
164165 then {}
165166 else {
lib/call-stack-to-nix.nix+1
@@ -20,6 +20,7 @@ let
2020 LOCALE_ARCHIVE = pkgs.lib.optionalString (pkgs.stdenv.hostPlatform.libc == "glibc") "${pkgs.glibcLocales}/lib/locale/locale-archive";
2121 LANG = "en_US.UTF-8";
2222 LC_ALL = "en_US.UTF-8";
23+ preferLocalBuild = false;
2324 } (''
2425 mkdir -p $out
2526 '' + pkgs.lib.optionalString (cache != null) ''
lib/check.nixnew file+42
@@ -0,0 +1,42 @@
1+{ stdenv, lib, haskellLib, srcOnly }:
2+drv:
3+
4+let
5+ component = drv.config;
6+
7+# This derivation can be used to execute test component.
8+# The $out of the derivation is a file containing the resulting
9+# stdout output.
10+in stdenv.mkDerivation ({
11+ name = (drv.name + "-check");
12+
13+ # Useing `srcOnly` (rather than getting the `src` via a `drv.passthru`)
14+ # should correctly apply the patches from `drv` (if any).
15+ src = srcOnly drv;
16+
17+ passthru = {
18+ inherit (drv) identifier config configFiles executableToolDepends cleanSrc env;
19+ };
20+
21+ inherit (drv) meta LANG LC_ALL;
22+
23+ inherit (component) doCheck doCrossCheck;
24+
25+ phases = ["buildPhase" "checkPhase"];
26+
27+ # If doCheck or doCrossCheck are false we may still build this
28+ # component and we want it to quietly succeed.
29+ buildPhase = ''
30+ touch $out
31+ '';
32+
33+ checkPhase = ''
34+ runHook preCheck
35+
36+ ${toString component.testWrapper} ${drv}/${drv.installedExe} ${lib.concatStringsSep " " component.testFlags} | tee $out
37+
38+ runHook postCheck
39+ '';
40+} // haskellLib.optionalHooks {
41+ inherit (component) preCheck postCheck;
42+})
lib/default.nix+6−1
@@ -1,4 +1,4 @@
1−{ lib, haskellLib, runCommand, git }:
1+{ stdenv, lib, haskellLib, runCommand, git, srcOnly }:
22
33with haskellLib;
44
@@ -149,4 +149,9 @@ with haskellLib;
149149 cleanGit = import ./clean-git.nix {
150150 inherit lib runCommand git cleanSourceWith;
151151 };
152+
153+ # Check a test component
154+ check = import ./check.nix {
155+ inherit stdenv lib haskellLib srcOnly;
156+ };
152157}
modules/plan.nix+1−1
@@ -81,7 +81,7 @@ let
8181 };
8282 doCheck = mkOption {
8383 type = bool;
84− default = (def.doCheck or false);
84+ default = (def.doCheck or true);
8585 };
8686 doCrossCheck = mkOption {
8787 description = "Run doCheck also in cross compilation settings. This can be tricky as the test logic must know how to run the tests on the target.";
overlays/bootstrap.nix+3−3
@@ -267,7 +267,7 @@ self: super: {
267267 index-state = "2019-10-20T00:00:00Z";
268268 plan-sha256 = "086kd6aa5bir3y4aqb1wl5zkj6agz5q4wp4snvdnf6cidz5wra06";
269269 };
270− alex = bootstrap.packages.alex-project.alex.components.exes.alex;
270+ alex = bootstrap.packages.alex-project.hsPkgs.alex.components.exes.alex;
271271 happy-project = hackage-project {
272272 # Only a boot compiler is suitable here
273273 ghc = ghc // { isHaskellNixCompiler = ghc.isHaskellNixBootCompiler; };
@@ -276,7 +276,7 @@ self: super: {
276276 index-state = "2019-10-20T00:00:00Z";
277277 plan-sha256 = "011bxlxdv239psgi80j00km2wcgb68j16sz3fng67d03sqf5i37w";
278278 };
279− happy = bootstrap.packages.happy-project.happy.components.exes.happy;
279+ happy = bootstrap.packages.happy-project.hsPkgs.happy.components.exes.happy;
280280 hscolour-project = hackage-project {
281281 # Only a boot compiler is suitable here
282282 ghc = ghc // { isHaskellNixCompiler = ghc.isHaskellNixBootCompiler; };
@@ -285,7 +285,7 @@ self: super: {
285285 index-state = "2019-10-20T00:00:00Z";
286286 plan-sha256 = "021rwcmkshibc3mfr833ay5hfr19kq6k32lxyrrb6vp9vmihgw4b";
287287 };
288− hscolour = bootstrap.packages.hscolour-project.hscolour.components.exes.HsColour;
288+ hscolour = bootstrap.packages.hscolour-project.hsPkgs.hscolour.components.exes.HsColour;
289289 };
290290 };
291291 };
overlays/haskell.nix+30−21
@@ -59,7 +59,7 @@ self: super: {
5959
6060 # Utility functions for working with the component builder.
6161 haskellLib = let hl = import ../lib {
62− inherit (self) lib runCommand;
62+ inherit (self) stdenv lib runCommand srcOnly;
6363 inherit (self.buildPackages) git;
6464 haskellLib = hl;
6565 }; in hl;
@@ -309,7 +309,7 @@ self: super: {
309309 tar xzf ${tarball}
310310 mv "${name}-${version}" $out
311311 '';
312− in cabalProject (builtins.removeAttrs args [ "version" ] // { inherit src; });
312+ in cabalProject' (builtins.removeAttrs args [ "version" ] // { inherit src; });
313313
314314 # This function is like `cabalProject` but it makes the plan-nix available
315315 # separately from the hsPkgs. The advantage is that the you can get the
@@ -361,27 +361,36 @@ self: super: {
361361 # project = cabalProject' {...};
362362 # In your tests module add something that is effectively
363363 # testProjectPlan = withInputs project.plan-nix;
364− withInputs = derivation: builtins.mapAttrs (_: self.recurseIntoAttrs) {
365− inherit derivation;
366− inputs = builtins.listToAttrs (
367− builtins.concatMap (i: if i == null then [] else [
368− { name = builtins.replaceStrings ["." (self.stdenv.hostPlatform.config + "-")] ["_" ""] i.name; value = i; }
369− ]) derivation.nativeBuildInputs);
370− };
364+ withInputs = self.recurseIntoAttrs;
371365
372366 # Add this to your tests to make all the dependencies of haskell.nix
373367 # are tested and cached.
374− haskellNixRoots = self.recurseIntoAttrs (builtins.mapAttrs (_: self.recurseIntoAttrs) {
375− inherit (self.buildPackages.haskell-nix) nix-tools source-pins;
376− bootstap-nix-tools = self.buildPackages.haskell-nix.bootstrap.packages.nix-tools;
377− alex-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.alex-project.plan-nix;
378− happy-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.happy-project.plan-nix;
379− hscolour-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.hscolour-project.plan-nix;
380− ghc-extra-projects = builtins.mapAttrs (_: proj: self.recurseIntoAttrs (withInputs proj.plan-nix))
381− (self.lib.filterAttrs (n: _: n != "ghc844" && n != "ghc861" && n != "ghc862"
382− # There is an issue with GHC 8.6.4 and nixpkgs 19.09, so only build it for 19.03 for now
383− && (n != "ghc864" || super.lib.versions.majorMinor super.lib.version == "19.03")
384− ) self.ghc-extra-projects);
385− });
368+ haskellNixRoots = self.recurseIntoAttrs {
369+ Level0 = haskellNixRoots' 0;
370+ Level1 = haskellNixRoots' 1;
371+ };
372+
373+ haskellNixRoots' = ifdLevel:
374+ let filterSupportedGhc = self.lib.filterAttrs (n: _: n == "ghc865");
375+ in self.recurseIntoAttrs ({
376+ # Things that require no IFD to build
377+ inherit (self.buildPackages.haskell-nix) nix-tools source-pins;
378+ bootstap-nix-tools = self.buildPackages.haskell-nix.bootstrap.packages.nix-tools;
379+ alex-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.alex-project.plan-nix;
380+ happy-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.happy-project.plan-nix;
381+ hscolour-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.hscolour-project.plan-nix;
382+ } // self.lib.optionalAttrs (ifdLevel > 0) {
383+ # Things that require one IFD to build (the inputs should be in level 0)
384+ alex = self.buildPackages.haskell-nix.bootstrap.packages.alex;
385+ happy = self.buildPackages.haskell-nix.bootstrap.packages.happy;
386+ hscolour = self.buildPackages.haskell-nix.bootstrap.packages.hscolour;
387+ ghc865 = self.buildPackages.haskell-nix.compiler.ghc865;
388+ ghc-extra-projects = self.recurseIntoAttrs (builtins.mapAttrs (_: proj: withInputs proj.plan-nix)
389+ (filterSupportedGhc self.ghc-extra-projects));
390+ } // self.lib.optionalAttrs (ifdLevel > 1) {
391+ # Things that require two levels of IFD to build (inputs should be in level 1)
392+ ghc-extra-packages = self.recurseIntoAttrs
393+ (filterSupportedGhc self.ghc-extra-packages);
394+ });
386395 };
387396}
package-set.nix+1−1
@@ -7,7 +7,7 @@ in pkgs.lib.evalModules {
77 _module.args = {
88 # this is *not* the hasekllLib from nixpkgs; it is rather our own
99 # library from haskell.nix
10− haskellLib = let hl = import ./lib { inherit lib; inherit (pkgs) runCommand git; haskellLib = hl; }; in hl;
10+ haskellLib = let hl = import ./lib { inherit lib; inherit (pkgs) stdenv runCommand git srcOnly; haskellLib = hl; }; in hl;
1111
1212 # The package descriptions depend on pkgs, which are used to resolve system package dependencies
1313 # as well as pkgconfPkgs, which are used to resolve pkgconfig name to nixpkgs names. We simply
release.nix+2
@@ -2,6 +2,7 @@
22, scrubJobs ? true
33, haskell-nix ? { outPath = ./.; rev = "abcdef"; }
44, nixpkgsArgs ? {}
5+, ifdLevel ? 3
56}:
67
78let defaultNixpkgs = import ./nixpkgs {}; in
@@ -31,6 +32,7 @@ let
3132 , ...}@args:
3233 import (haskell-nix + /build.nix) (args // {
3334 nixpkgsArgs = nixpkgsArgs // { inherit nixpkgs-pin; };
35+ inherit ifdLevel;
3436 });
3537 });
3638
scripts/check-hydra.nix+2−1
@@ -9,11 +9,12 @@ writeScript "check-hydra.sh" ''
99
1010 export PATH="${makeBinPath [ coreutils time gnutar gzip hydra jq ]}"
1111
12− echo '~~~ Evaluating release.nix'
12+ echo '~~~ Evaluating release.nix with --arg ifdLevel '$1
1313 command time --format '%e' -o eval-time.txt \
1414 hydra-eval-jobs \
1515 --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \
1616 --arg supportedSystems '[ builtins.currentSystem ]' \
17+ --arg ifdLevel $1 \
1718 -I . release.nix > eval.json
1819 EVAL_EXIT_CODE="$?"
1920 if [ "$EVAL_EXIT_CODE" != 0 ]
test/buildable/default.nix+4−2
@@ -12,14 +12,16 @@ let
1212 packages = project.hsPkgs;
1313
1414in recurseIntoAttrs {
15− inherit (project) plan-nix;
15+ ifdInputs = {
16+ inherit (project) plan-nix;
17+ };
1618 run = stdenv.mkDerivation {
1719 name = "buildable-test";
1820
1921 buildCommand =
2022 (concatStrings (mapAttrsToList (name: value: ''
2123 printf "checking whether executable runs... " >& 2
22− cat ${value.run}
24+ cat ${haskellLib.check value}
2325 '') packages.buildable-test.components.exes)) + ''
2426 touch $out
2527 '';
test/cabal-22/default.nix+6−4
@@ -11,7 +11,9 @@ let
1111 packages = project.hsPkgs;
1212
1313in recurseIntoAttrs {
14− inherit (project) plan-nix;
14+ ifdInputs = {
15+ inherit (project) plan-nix;
16+ };
1517 shell = util.addCabalInstall packages.project.components.all;
1618 run = stdenv.mkDerivation {
1719 name = "cabal-22-test";
@@ -24,7 +26,7 @@ in recurseIntoAttrs {
2426
2527 # fixme: run on target platform when cross-compiled
2628 printf "checking whether executable rans... " >& 2
27− cat ${packages.project.components.exes.project.run}
29+ cat ${haskellLib.check packages.project.components.exes.project}
2830
2931 printf "checking that executable is dynamically linked to system libraries... " >& 2
3032 '' + optionalString stdenv.isLinux ''
@@ -50,10 +52,10 @@ in recurseIntoAttrs {
5052 touch $out
5153
5254 printf "checking whether benchmark ran... " >& 2
53− cat ${packages.project.components.benchmarks.project-bench.run}
55+ cat ${haskellLib.check packages.project.components.benchmarks.project-bench}
5456
5557 printf "checking whether tests ran... " >& 2
56− cat ${packages.project.components.tests.unit.run}
58+ cat ${haskellLib.check packages.project.components.tests.unit}
5759 '';
5860
5961 meta.platforms = platforms.all;
test/cabal-simple-prof/default.nix+3−1
@@ -24,7 +24,9 @@ let
2424 packages = project.hsPkgs;
2525
2626in recurseIntoAttrs {
27− inherit (project) plan-nix;
27+ ifdInputs = {
28+ inherit (project) plan-nix;
29+ };
2830 run = stdenv.mkDerivation {
2931 name = "cabal-simple-prof-test";
3032
test/cabal-simple/default.nix+4−2
@@ -34,7 +34,9 @@ let
3434 packages = project.hsPkgs;
3535
3636in recurseIntoAttrs {
37− inherit (project) plan-nix;
37+ ifdInputs = {
38+ inherit (project) plan-nix;
39+ };
3840
3941 # Used for testing externally with nix-shell (../tests.sh).
4042 # This just adds cabal-install to the existing shells.
@@ -51,7 +53,7 @@ in recurseIntoAttrs {
5153
5254 # fixme: run on target platform when cross-compiled
5355 printf "checking whether executable runs... " >& 2
54− cat ${packages.cabal-simple.components.exes.cabal-simple.run}
56+ cat ${haskellLib.check packages.cabal-simple.components.exes.cabal-simple}
5557 '' + (if stdenv.hostPlatform.isMusl then ''
5658 printf "checking that executable is statically linked... " >& 2
5759 (ldd $exe 2>&1 || true) | grep -i "not a"
test/cabal-source-repo/default.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, cabalProject', recurseIntoAttrs }:
1+{ stdenv, cabalProject', recurseIntoAttrs, haskellLib }:
22
33with stdenv.lib;
44
@@ -10,7 +10,9 @@ let
1010 };
1111 packages = project.hsPkgs;
1212in recurseIntoAttrs {
13− inherit (project) plan-nix;
13+ ifdInputs = {
14+ inherit (project) plan-nix;
15+ };
1416 run = stdenv.mkDerivation {
1517 name = "call-cabal-project-to-nix-test";
1618
@@ -18,7 +20,7 @@ in recurseIntoAttrs {
1820 exe="${packages.use-cabal-simple.components.exes.use-cabal-simple}/bin/use-cabal-simple${stdenv.hostPlatform.extensions.executable}"
1921
2022 printf "checking whether executable runs... " >& 2
21− cat ${packages.use-cabal-simple.components.exes.use-cabal-simple.run}
23+ cat ${haskellLib.check packages.use-cabal-simple.components.exes.use-cabal-simple}
2224
2325 touch $out
2426 '';
test/cabal-sublib/default.nix+4−2
@@ -22,7 +22,9 @@ let
2222 packages = project.hsPkgs;
2323
2424in recurseIntoAttrs {
25− inherit (project) plan-nix;
25+ ifdInputs = {
26+ inherit (project) plan-nix;
27+ };
2628 run = stdenv.mkDerivation {
2729 name = "cabal-sublib-test";
2830
@@ -34,7 +36,7 @@ in recurseIntoAttrs {
3436
3537 # fixme: run on target platform when cross-compiled
3638 printf "checking whether executable runs... " >& 2
37− cat ${packages.cabal-sublib.components.exes.cabal-sublib.run}
39+ cat ${haskellLib.check packages.cabal-sublib.components.exes.cabal-sublib}
3840
3941 printf "checking that executable is dynamically linked to system libraries... " >& 2
4042 '' + optionalString stdenv.isLinux ''
test/call-cabal-project-to-nix/default.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject, recurseIntoAttrs }:
1+{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject, recurseIntoAttrs, haskellLib }:
22
33with stdenv.lib;
44
@@ -17,7 +17,9 @@ let
1717 packages = pkgSet.config.hsPkgs;
1818
1919in recurseIntoAttrs {
20− plan-nix = plan.nix;
20+ ifdInputs = {
21+ plan-nix = plan.nix;
22+ };
2123 run = stdenv.mkDerivation {
2224 name = "call-cabal-project-to-nix-test";
2325
@@ -25,7 +27,7 @@ in recurseIntoAttrs {
2527 exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}"
2628
2729 printf "checking whether executable runs... " >& 2
28− cat ${packages.cabal-simple.components.exes.cabal-simple.run}
30+ cat ${haskellLib.check packages.cabal-simple.components.exes.cabal-simple}
2931
3032 touch $out
3133 '';
test/call-stack-to-nix/default.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, mkStackPkgSet, callStackToNix, importAndFilterProject, recurseIntoAttrs }:
1+{ stdenv, mkStackPkgSet, callStackToNix, importAndFilterProject, recurseIntoAttrs, haskellLib }:
22
33with stdenv.lib;
44
@@ -14,7 +14,9 @@ let
1414 packages = pkgSet.config.hsPkgs;
1515
1616in recurseIntoAttrs {
17− stack-nix = stack.nix;
17+ ifdInputs = {
18+ stack-nix = stack.nix;
19+ };
1820 run = stdenv.mkDerivation {
1921 name = "callStackToNix-test";
2022
@@ -22,7 +24,7 @@ in recurseIntoAttrs {
2224 exe="${packages.stack-simple.components.exes.stack-simple-exe}/bin/stack-simple-exe${stdenv.hostPlatform.extensions.executable}"
2325
2426 printf "checking whether executable runs... " >& 2
25− cat ${packages.stack-simple.components.exes.stack-simple-exe.run}
27+ cat ${haskellLib.check packages.stack-simple.components.exes.stack-simple-exe}
2628
2729 touch $out
2830 '';
test/default.nix+11−2
@@ -1,14 +1,23 @@
11{ pkgs ? import nixpkgs ((import ../.) // nixpkgsArgs)
22, nixpkgs ? ../nixpkgs
33, nixpkgsArgs ? { }
4+, ifdLevel ? 1000
45}:
56
67with pkgs;
78
89let
10+ withIfdInputs = builtins.mapAttrs (n: x:
11+ if n == "ifdInputs"
12+ then pkgs.recurseIntoAttrs (builtins.mapAttrs (_: pkgs.haskell-nix.withInputs) x)
13+ else x);
914 util = import ./util.nix { inherit (pkgs.haskell-nix) cabal-install; };
1015in pkgs.recurseIntoAttrs {
11− inherit (haskell-nix) haskellNixRoots;
16+ haskellNixRoots = haskell-nix.haskellNixRoots' ifdLevel;
17+} // pkgs.lib.optionalAttrs (ifdLevel > 1) (
18+ builtins.mapAttrs (_: y: withIfdInputs y) ((if ifdLevel < 3
19+ then builtins.mapAttrs (_: d: pkgs.recurseIntoAttrs (pkgs.lib.filterAttrs (n: _: n == "ifdInputs") d))
20+ else x: x) {
1221 cabal-simple = haskell-nix.callPackage ./cabal-simple { inherit util; };
1322 cabal-simple-prof = haskell-nix.callPackage ./cabal-simple-prof { inherit util; };
1423 cabal-sublib = haskell-nix.callPackage ./cabal-sublib { inherit util; };
@@ -38,7 +47,7 @@ in pkgs.recurseIntoAttrs {
3847 in runCommand "unit-tests" { passthru = { inherit tests; }; }
3948 (lib.concatMapStringsSep "\n" (t: "echo ${t.name} failed") tests +
4049 (if builtins.length tests == 0 then "\ntouch $out" else "\nexit 1"));
41−}
50+}))
4251
4352## more possible test cases
4453# 1. fully static linking
test/exe-only/default.nix+5−3
@@ -1,5 +1,5 @@
11# Test a package set
2−{ stdenv, util, haskell-nix, recurseIntoAttrs }:
2+{ stdenv, util, haskell-nix, recurseIntoAttrs, haskellLib }:
33
44with stdenv.lib;
55
@@ -12,7 +12,9 @@ let
1212 packages = project.hsPkgs;
1313
1414in recurseIntoAttrs {
15− inherit (project) plan-nix;
15+ ifdInputs = {
16+ inherit (project) plan-nix;
17+ };
1618 run = stdenv.mkDerivation {
1719 name = "exe-only-test";
1820
@@ -24,7 +26,7 @@ in recurseIntoAttrs {
2426
2527 # fixme: run on target platform when cross-compiled
2628 printf "checking whether executable ran... " >& 2
27− cat ${packages.exe-only.components.exes.exe-only.run}
29+ cat ${haskellLib.check packages.exe-only.components.exes.exe-only}
2830 '' + (if stdenv.hostPlatform.isMusl then ''
2931 printf "checking that executable is statically linked... " >& 2
3032 (ldd $exe 2>&1 || true) | grep -i "not a"
test/fully-static/default.nix+4−2
@@ -53,8 +53,10 @@ let
5353 packagesIntegerSimple = (project { gpl = false; }).hsPkgs;
5454
5555in recurseIntoAttrs {
56− stack-nix-gmp = (project { gpl = true; }).stack-nix;
57− stack-nix-simple = (project { gpl = false; }).stack-nix;
56+ ifdInputs = {
57+ stack-nix-gmp = (project { gpl = true; }).stack-nix;
58+ stack-nix-simple = (project { gpl = false; }).stack-nix;
59+ };
5860 run = stdenv.mkDerivation {
5961 name = "fully-static-test";
6062
test/ghc-options/cabal.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, cabalProject', recurseIntoAttrs }:
1+{ stdenv, cabalProject', recurseIntoAttrs, haskellLib }:
22
33with stdenv.lib;
44
@@ -13,13 +13,15 @@ let
1313 packages = project.hsPkgs;
1414
1515in recurseIntoAttrs {
16− inherit (project) plan-nix;
16+ ifdInputs = {
17+ inherit (project) plan-nix;
18+ };
1719 run = stdenv.mkDerivation {
1820 name = "call-cabal-project-to-nix-test";
1921
2022 buildCommand = ''
2123 printf "checking whether executable runs... " >& 2
22− cat ${packages.test-ghc-options.components.exes.test-ghc-options-exe.run}
24+ cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}
2325
2426 touch $out
2527 '';
test/ghc-options/stack.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, stackProject', recurseIntoAttrs }:
1+{ stdenv, stackProject', recurseIntoAttrs, haskellLib }:
22
33with stdenv.lib;
44
@@ -9,13 +9,15 @@ let
99 packages = project.hsPkgs;
1010
1111in recurseIntoAttrs {
12− inherit (project) stack-nix;
12+ ifdInputs = {
13+ inherit (project) stack-nix;
14+ };
1315 run = stdenv.mkDerivation {
1416 name = "callStackToNix-test";
1517
1618 buildCommand = ''
1719 printf "checking whether executable runs... " >& 2
18− cat ${packages.test-ghc-options.components.exes.test-ghc-options-exe.run}
20+ cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}
1921
2022 touch $out
2123 '';
test/project-flags/cabal.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, cabalProject', recurseIntoAttrs }:
1+{ stdenv, cabalProject', recurseIntoAttrs, haskellLib }:
22
33with stdenv.lib;
44
@@ -11,7 +11,9 @@ let
1111 packages = project.hsPkgs;
1212
1313in recurseIntoAttrs {
14− inherit (project) plan-nix;
14+ ifdInputs = {
15+ inherit (project) plan-nix;
16+ };
1517 run = stdenv.mkDerivation {
1618 name = "call-cabal-project-to-nix-test";
1719
@@ -19,7 +21,7 @@ in recurseIntoAttrs {
1921 exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe${stdenv.hostPlatform.extensions.executable}"
2022
2123 printf "checking whether executable runs... " >& 2
22− cat ${packages.test-project-flags.components.exes.test-project-flags-exe.run}
24+ cat ${haskellLib.check packages.test-project-flags.components.exes.test-project-flags-exe}
2325
2426 touch $out
2527 '';
test/project-flags/stack.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, stackProject', recurseIntoAttrs }:
1+{ stdenv, stackProject', recurseIntoAttrs, haskellLib }:
22
33with stdenv.lib;
44
@@ -9,7 +9,9 @@ let
99 packages = project.hsPkgs;
1010
1111in recurseIntoAttrs {
12− inherit (project) stack-nix;
12+ ifdInputs = {
13+ inherit (project) stack-nix;
14+ };
1315 run = stdenv.mkDerivation {
1416 name = "callStackToNix-test";
1517
@@ -17,7 +19,7 @@ in recurseIntoAttrs {
1719 exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe${stdenv.hostPlatform.extensions.executable}"
1820
1921 printf "checking whether executable runs... " >& 2
20− cat ${packages.test-project-flags.components.exes.test-project-flags-exe.run}
22+ cat ${haskellLib.check packages.test-project-flags.components.exes.test-project-flags-exe}
2123
2224 touch $out
2325 '';
test/setup-deps/default.nix+4−2
@@ -23,11 +23,13 @@ in recurseIntoAttrs (if stdenv.hostPlatform.isWindows
2323 touch $out
2424 '';
2525 in {
26− plan-nix = skip;
26+ ifdInputs = { plan-nix = skip; };
2727 run = skip;
2828 }
2929 else {
30− inherit (project) plan-nix;
30+ ifdInputs = {
31+ inherit (project) plan-nix;
32+ };
3133 run = pkgs.stdenv.mkDerivation {
3234 name = "setup-deps-test";
3335
test/shell-for-setup-deps/default.nix+4−2
@@ -22,12 +22,14 @@ in recurseIntoAttrs (if stdenv.hostPlatform.isWindows
2222 touch $out
2323 '';
2424 in {
25− plan-nix = skip;
25+ ifdInputs = { plan-nix = skip; };
2626 env = skip;
2727 run = skip;
2828 }
2929 else {
30− inherit (project) plan-nix;
30+ ifdInputs = {
31+ inherit (project) plan-nix;
32+ };
3133 inherit env;
3234 run = stdenv.mkDerivation {
3335 name = "shell-for-test";
test/stack-simple/default.nix+4−3
@@ -1,4 +1,4 @@
1−{ stdenv, pkgs, mkStackPkgSet }:
1+{ stdenv, pkgs, mkStackPkgSet, haskellLib }:
22
33with stdenv.lib;
44
@@ -14,9 +14,10 @@ let
1414 packages = pkgSet.config.hsPkgs;
1515
1616in pkgs.recurseIntoAttrs {
17− stack-simple-exe = packages.stack-simple.components.exes.stack-simple-exe.run // {
17+ stack-simple-exe = (haskellLib.check packages.stack-simple.components.exes.stack-simple-exe) // {
1818 # Attributes used for debugging with nix repl
1919 inherit pkgSet packages;
2020 };
21− stack-simple-test = packages.stack-simple.components.tests.stack-simple-test.run;
21+ stack-simple-test = packages.stack-simple.checks.stack-simple-test;
22+ stack-simple-checks = packages.stack-simple.checks;
2223}