on iko/ghcjs-patch-master help sign in
Fix evaluation on Hydra (#153)

* Fix eval on Hydra * Bump nixpkgs to latest 19.03 * Change unit tests into a derivation Prevents Hydra from complaining about them. * Add unpacked source pins to Hydra jobset So that they are cached.

commit8512832c32025564c49c59b7bff3e8f49f0afdf4 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateSun 2 Jun 2019, 07:21 (7 years ago) parent831f372
7 files changed+41−14
default.nix+11−4 lib/make-source-pins.nix+11 nixpkgs/default.nix+5−1 nixpkgs/github.json+3−3 release.nix+2−1 test/default.nix+8−4 test/tests.sh+1−1
default.nix+11−4
@@ -43,18 +43,20 @@ let
4343 cleanSourceHaskell = pkgs.callPackage ./lib/clean-source-haskell.nix {};
4444
4545 # All packages from Hackage as Nix expressions
46− hackage = import (fetchExternal {
46+ hackageSrc = fetchExternal {
4747 name = "hackage-exprs-source";
4848 specJSON = hackageSourceJSON;
4949 override = "hackage";
50− });
50+ };
51+ hackage = import hackageSrc;
5152
5253 # The set of all Stackage snapshots
53− stackage = import (fetchExternal {
54+ stackageSrc = fetchExternal {
5455 name = "stackage-snapshot-source";
5556 specJSON = stackageSourceJSON;
5657 override = "stackage";
57− });
58+ };
59+ stackage = import stackageSrc;
5860
5961 packages = self: ({
6062 # Utility functions for working with the component builder.
@@ -196,6 +198,11 @@ let
196198 inherit (pkgs.haskellPackages) hpack;
197199 inherit (self) nix-tools;
198200 };
201+
202+ # References to the unpacked sources, for caching in a Hydra jobset.
203+ source-pins = self.callPackage ./lib/make-source-pins.nix {
204+ sources = [ hackageSrc stackageSrc pkgs.path ];
205+ };
199206 });
200207
201208in
lib/make-source-pins.nixnew file+11
@@ -0,0 +1,11 @@
1+# Writes the store paths of a list of sources into a file.
2+# If this derivation is built by Hydra, then the sources will
3+# be kept and will be available to download from the binary cache.
4+{ lib, writeTextFile
5+, sources # A list of paths
6+}:
7+
8+writeTextFile {
9+ name = "haskell.nix-source-pins";
10+ text = lib.concatMapStringsSep "\n" toString sources;
11+}
nixpkgs/default.nix+5−1
@@ -2,5 +2,9 @@ let
22 fetch = jsonFile:
33 with builtins;
44 let spec = fromJSON (readFile jsonFile);
5− in fetchTarball { inherit (spec) sha256; url = "${spec.url}/archive/${spec.rev}.tar.gz"; };
5+ in fetchTarball {
6+ name = "nixpkgs";
7+ inherit (spec) sha256;
8+ url = "${spec.url}/archive/${spec.rev}.tar.gz";
9+ };
610in import (fetch ./github.json)
nixpkgs/github.json+3−3
@@ -1,7 +1,7 @@
11{
2− "url": "https://github.com/nixos/nixpkgs",
3− "rev": "db85ded4aae63508934dc42064c7fbff16e0ec21",
2+ "url": "https://github.com/NixOS/nixpkgs",
3+ "rev": "0728c3e026e3ac2542a9673d57533829e552e218",
44 "date": "2019-05-17T15:35:26+02:00",
5− "sha256": "0b91n0s5zaamxh9842ns11s40678sv4pbpxaxdqnrnkrkp8pn9gy",
5+ "sha256": "0sp8giack8na9hdm8ivk969mpwfcavqrfy7kncx0a1hs1ykw15hy",
66 "fetchSubmodules": false
77}
release.nix+2−1
@@ -1,6 +1,7 @@
11let
22 haskell = import ./default.nix {};
33in {
4− inherit (haskell) nix-tools;
4+ inherit (haskell) nix-tools source-pins;
5+
56 tests = import ./test { inherit haskell; };
67}
test/default.nix+8−4
@@ -18,12 +18,16 @@ in {
1818 stack-simple = haskell.callPackage ./stack-simple {};
1919 snapshots = haskell.callPackage ./snapshots {};
2020 shell-for = haskell.callPackage ./shell-for {};
21− callStackToNix = haskell.callPackage ./callStackToNix {};
22− callCabalProjectToNix = haskell.callPackage ./call-cabal-project-to-nix {};
21+ # callStackToNix = haskell.callPackage ./callStackToNix {};
22+ # callCabalProjectToNix = haskell.callPackage ./call-cabal-project-to-nix {};
2323
24− # Run unit tests with: nix-instantiate --eval --strict -A unit
24+ # Run unit tests with: nix-instantiate --eval --strict -A unit.tests
2525 # An empty list means success.
26− unit = haskell.callPackage ./unit.nix {};
26+ unit = let
27+ tests = haskell.callPackage ./unit.nix {};
28+ in runCommand "unit-tests" { passthru = { inherit tests; }; }
29+ (lib.concatMapStringsSep "\n" (t: "echo ${t.name} failed") tests +
30+ (if builtins.length tests == 0 then "\ntouch $out" else "\nexit 1"));
2731}
2832
2933## more possible test cases
test/tests.sh+1−1
@@ -16,7 +16,7 @@ nix build $NIX_BUILD_ARGS --no-link --keep-going -f ./default.nix
1616echo >& 2
1717
1818printf "*** Running the unit tests... " >& 2
19−res=$(nix-instantiate --eval --json --strict ./default.nix -A unit)
19+res=$(nix-instantiate --eval --json --strict ./default.nix -A unit.tests)
2020num_failed=$(jq length <<< "$res")
2121if [ $num_failed -eq 0 ]; then
2222 printf "PASSED\n" >& 2