on iko/ghcjs-patch-master help sign in
Test setup deps issue depending on ghc and Cabal (#278)

Projects like asterius and leksah that include dependencies on ghc. Sometimes the are needed by a setup.hs file (as is the case for the binaryen package used by asterius). The recent overlays merge broke this and #279 was needed to allow reinstallableLibGhc to be used to fix it. This PR adds a test case to make sure it is not inadvertently broken again. Also gives us a place to try out better ways to make this type of package work.* Test setup deps issue depending on ghc and Cabal * Uses nixpkgs 19.09 + macOS wine fix on hydra/buildkite * Enables macOS hydra tests * disables musl tests for now * Adds haskellNixRoots to tests * Uses reinstallableLibGhc to fix the new setup-depends test * Adds meta.platforms to haskell.nix components * Set meta.platforms on cabal-install * Builds some maintainer-scripts on hydra * Pins hackage index-state for ghc-extra-packages

commita5f9f45922fa93fdbc2253d407fe05b5c890652c authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateFri 1 Nov 2019, 12:34 (7 years ago) parente15c59b
16 files changed+164−9
build.nix+15−2 builder/comp-builder.nix+1 builder/setup-builder.nix+11 compiler/bootstrap/cabal-install.nix+4 modules/package.nix+5 nixpkgs/github.json+4−4 overlays/ghc-packages.nix+1 release.nix+3−2 scripts/check-hydra.nix+1 test/default.nix+3−1 test/setup-deps/cabal.project+3 test/setup-deps/default.nix+39 test/setup-deps/pkg/Setup.hs+27 test/setup-deps/pkg/app/Main.hs+6 test/setup-deps/pkg/pkg.cabal+36 test/setup-deps/pkg/src/conduit-test.hs+5
build.nix+15−2
@@ -20,17 +20,20 @@ let
2020 darcs = (self.haskell-nix.hackage-package {
2121 name = "darcs";
2222 version = "2.14.2";
23+ index-state = "2019-10-28T00:00:00Z";
2324 # Apply the latest darcs.net Setup.hs patches
2425 modules = [{packages.darcs.patches = [ ./patches/darcs-setup.patch ];}];
2526 }).components.exes.darcs;
2627 })]; } // nixpkgsArgs);
2728 haskell = pkgs.haskell-nix;
2829
29−in {
30− inherit (haskell) haskellNixRoots;
30+in rec {
3131 tests = import ./test/default.nix { inherit nixpkgs nixpkgsArgs; };
3232
3333 # Scripts for keeping Hackage and Stackage up to date, and CI tasks.
34+ # The dontRecurseIntoAttrs prevents these from building on hydra
35+ # as not all of them can work in restricted eval mode (as they
36+ # are not pure).
3437 maintainer-scripts = pkgs.dontRecurseIntoAttrs {
3538 update-hackage = haskell.callPackage ./scripts/update-hackage.nix {};
3639 update-stackage = haskell.callPackage ./scripts/update-stackage.nix {};
@@ -51,4 +54,14 @@ in {
5154 check-hydra = haskell.callPackage ./scripts/check-hydra.nix {};
5255 check-closure-size = haskell.callPackage ./scripts/check-closure-size.nix {};
5356 };
57+
58+ # These are pure parts of maintainer-script so they can be built by hydra
59+ # and added to the cache to speed up buildkite.
60+ maintainer-script-cache = pkgs.recurseIntoAttrs {
61+ inherit (maintainer-scripts) update-docs check-hydra check-closure-size;
62+ # Some of the dependencies of the impure scripts so that they will
63+ # will be in the cache too for buildkite.
64+ inherit (pkgs) coreutils glibc git openssh cabal-install nix-prefetch-git;
65+ inherit (haskell) nix-tools;
66+ };
5467}
builder/comp-builder.nix+1
@@ -146,6 +146,7 @@ stdenv.mkDerivation ({
146146 license-map = import ../lib/cabal-licenses.nix lib;
147147 in license-map.${package.license} or
148148 (builtins.trace "WARNING: license \"${package.license}\" not found" license-map.LicenseRef-OtherLicense);
149+ platforms = if component.platforms == null then stdenv.lib.platforms.all else component.platforms;
149150 };
150151
151152 LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.
builder/setup-builder.nix+11
@@ -41,6 +41,17 @@ in
4141 inherit configFiles cleanSrc;
4242 };
4343
44+ meta = {
45+ homepage = package.homepage;
46+ description = package.synopsis;
47+ license =
48+ let
49+ license-map = import ../lib/cabal-licenses.nix lib;
50+ in license-map.${package.license} or
51+ (builtins.trace "WARNING: license \"${package.license}\" not found" license-map.LicenseRef-OtherLicense);
52+ platforms = if component.platforms == null then stdenv.lib.platforms.all else component.platforms;
53+ };
54+
4455 phases = ["unpackPhase" "patchPhase" "buildPhase" "installPhase"];
4556 buildPhase = ''
4657 if [[ ! -f ./Setup.hs && ! -f ./Setup.lhs ]]; then
compiler/bootstrap/cabal-install.nix+4
@@ -41,6 +41,10 @@ in stdenv.mkDerivation ({
4141 inherit version;
4242 };
4343
44+ meta = {
45+ platforms = stdenv.lib.platforms.all;
46+ };
47+
4448 nativeBuildInputs = [ ghc zlib ];
4549
4650 inherit src;
modules/package.nix+5
@@ -210,6 +210,10 @@ in {
210210 type = listOfFilteringNulls unspecified;
211211 default = [];
212212 };
213+ platforms = mkOption {
214+ type = nullOr (listOfFilteringNulls unspecified);
215+ default = null;
216+ };
213217 };
214218 };
215219 in {
@@ -232,6 +236,7 @@ in {
232236 cxxSources = [];
233237 jsSources = [];
234238 extraSrcFiles = [ "Setup.hs" "Setup.lhs" ];
239+ platforms = null;
235240 };
236241 };
237242 library = mkOption {
nixpkgs/github.json+4−4
@@ -1,7 +1,7 @@
11{
2− "url": "https://github.com/NixOS/nixpkgs",
3− "rev": "5000b1478a11acbff7d95519c7300f3e6691885d",
4− "date": "2019-10-13T18:41:59-04:00",
5− "sha256": "0yyhkf48b15dcnq0gbiyi4ypjn09a0mpy6v7yilidwqydmkc0wxr",
2+ "url": "https://github.com/input-output-hk/nixpkgs",
3+ "rev": "3d623a406cec9052ae0a16a79ce3ce9de11236bb",
4+ "date": "2019-10-18T17:51:24+13:00",
5+ "sha256": "1a4yd980ylh1ygvmws15wldifz7jxjy8z07vc914kam1p25yjpj1",
66 "fetchSubmodules": false
77}
overlays/ghc-packages.nix+1
@@ -84,6 +84,7 @@ in rec {
8484 ghc-extra-projects = builtins.mapAttrs (name: proj: self.haskell-nix.cabalProject' {
8585 name = "ghc-extra-packages";
8686 src = proj;
87+ index-state = "2019-10-31T00:00:00Z";
8788 ghc = self.buildPackages.haskell.compiler.${name};
8889 })
8990 ghc-extra-pkgs-cabal-projects;
release.nix+3−2
@@ -1,4 +1,4 @@
1−{ supportedSystems ? [ "x86_64-linux" ] # spare our "x86_64-darwin" builders for now
1+{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
22, scrubJobs ? true
33, haskell-nix ? { outPath = ./.; rev = "abcdef"; }
44, nixpkgsArgs ? {}
@@ -24,7 +24,8 @@ let
2424
2525 jobs = {
2626 native = filterTests (mapTestOn (packagePlatforms pkgs));
27− "${musl64.config}" = filterTests (mapTestOnCross musl64 (packagePlatforms pkgs));
27+ # Disabled for now. Something is wrong and this would require `allowBroken`
28+ # "${musl64.config}" = filterTests (mapTestOnCross musl64 (packagePlatforms pkgs));
2829 } // {
2930 # On IOHK Hydra, "required" is a special job that updates the
3031 # GitHub CI status.
scripts/check-hydra.nix+1
@@ -13,6 +13,7 @@ writeScript "check-hydra.sh" ''
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" \
16+ --arg supportedSystems '[ builtins.currentSystem ]' \
1617 -I . release.nix > eval.json
1718 EVAL_EXIT_CODE="$?"
1819 if [ "$EVAL_EXIT_CODE" != 0 ]
test/default.nix+3−1
@@ -1,5 +1,5 @@
11{ pkgs ? import nixpkgs ((import ../.) // nixpkgsArgs)
2−, nixpkgs ? <nixpkgs>
2+, nixpkgs ? ../nixpkgs
33, nixpkgsArgs ? { }
44}:
55
@@ -8,6 +8,7 @@ with pkgs;
88let
99 util = callPackage ./util.nix {};
1010in pkgs.recurseIntoAttrs {
11+ inherit (haskell-nix) haskellNixRoots;
1112 cabal-simple = haskell-nix.callPackage ./cabal-simple { inherit util; };
1213 cabal-simple-prof = haskell-nix.callPackage ./cabal-simple-prof { inherit util; };
1314 cabal-sublib = haskell-nix.callPackage ./cabal-sublib { inherit util; };
@@ -18,6 +19,7 @@ in pkgs.recurseIntoAttrs {
1819 snapshots = haskell-nix.callPackage ./snapshots {};
1920 shell-for = haskell-nix.callPackage ./shell-for {};
2021 shell-for-setup-deps = haskell-nix.callPackage ./shell-for-setup-deps {};
22+ setup-deps = import ./setup-deps { inherit pkgs; };
2123 callStackToNix = haskell-nix.callPackage ./call-stack-to-nix {};
2224 callCabalProjectToNix = haskell-nix.callPackage ./call-cabal-project-to-nix {};
2325 cabal-source-repo = haskell-nix.callPackage ./cabal-source-repo {};
test/setup-deps/cabal.projectnew file+3
@@ -0,0 +1,3 @@
1+index-state: 2019-10-01T00:00:00Z
2+
3+packages: pkg
test/setup-deps/default.nixnew file+39
@@ -0,0 +1,39 @@
1+{ pkgs }:
2+
3+with pkgs;
4+with stdenv.lib;
5+
6+let
7+ project = haskell-nix.cabalProject' {
8+ src = ./.;
9+ modules = [{
10+ # Package has no exposed modules which causes
11+ # haddock: No input file(s)
12+ packages.bytestring-builder.doHaddock = false;
13+ }
14+ { reinstallableLibGhc = true; } ];
15+ };
16+
17+ packages = project.hsPkgs;
18+in recurseIntoAttrs {
19+ plan = haskell-nix.withInputs project.plan-nix;
20+ run = pkgs.stdenv.mkDerivation {
21+ name = "call-cabal-project-to-nix-test";
22+
23+ buildCommand = ''
24+ exe="${packages.pkg.components.exes.pkg}/bin/pkg"
25+
26+ printf "checking whether executable runs... " >& 2
27+ $exe
28+
29+ touch $out
30+ '';
31+
32+ meta.platforms = platforms.all;
33+
34+ passthru = {
35+ # Attributes used for debugging with nix repl
36+ inherit project packages;
37+ };
38+ };
39+}
test/setup-deps/pkg/Setup.hsnew file+27
@@ -0,0 +1,27 @@
1+import Distribution.Simple
2+
3+-- https://github.com/snoyberg/conduit#readme
4+
5+import Conduit
6+import System.Directory (removeFile)
7+
8+-- Make sure Cabal and ghc were included
9+import Distribution.Package ()
10+import Ar ()
11+
12+example = do
13+ -- Pure operations: summing numbers.
14+ print $ runConduitPure $ yieldMany [1..10] .| sumC
15+
16+ -- Exception safe file access: copy a file.
17+ writeFile "input.txt" "This is a test." -- create the source file
18+ runConduitRes $ sourceFileBS "input.txt" .| sinkFile "output.txt" -- actual copying
19+ readFile "output.txt" >>= putStrLn -- prove that it worked
20+
21+ -- Perform transformations.
22+ print $ runConduitPure $ yieldMany [1..10] .| mapC (+ 1) .| sinkList
23+
24+ removeFile "input.txt"
25+ removeFile "output.txt"
26+
27+main = defaultMain
test/setup-deps/pkg/app/Main.hsnew file+6
@@ -0,0 +1,6 @@
1+module Main where
2+
3+import qualified Data.Text.IO as T
4+
5+main :: IO ()
6+main = return ()
test/setup-deps/pkg/pkg.cabalnew file+36
@@ -0,0 +1,36 @@
1+cabal-version: 2.2
2+-- Initial package description 'pkgb.cabal' generated by 'cabal init'. For
3+-- further documentation, see http://haskell.org/cabal/users-guide/
4+
5+name: pkg
6+version: 0.1.0.0
7+-- synopsis:
8+-- description:
9+-- bug-reports:
10+license: LicenseRef-PublicDomain
11+author: Rodney Lorrimar
12+maintainer: rodney.lorrimar@iohk.io
13+category: Testing
14+
15+custom-setup
16+ setup-depends: conduit
17+ , conduit-extra
18+ , Cabal
19+ , ghc
20+
21+library
22+ exposed-modules: Pkg
23+ build-depends: base
24+ hs-source-dirs: src
25+ default-language: Haskell2010
26+ build-tools: alex, happy
27+
28+executable pkg
29+ main-is: Main.hs
30+ -- other-modules:
31+ -- other-extensions:
32+ build-depends: base
33+ , optparse-applicative
34+ , text
35+ hs-source-dirs: app
36+ default-language: Haskell2010
test/setup-deps/pkg/src/conduit-test.hsnew file+5
@@ -0,0 +1,5 @@
1+module Main where
2+
3+import Conduit
4+
5+main = return ()