diff --git a/build.nix b/build.nix index 7f74b75e..7acf14ba 100644 --- a/build.nix +++ b/build.nix @@ -21,6 +21,7 @@ let name = "darcs"; version = "2.14.2"; index-state = "2019-10-28T00:00:00Z"; + plan-sha256 = "1h8dxib0wz6mg8md6ldwa54dsr1dn7vxfij8cfhdawl4y3wr51k0"; # Apply the latest darcs.net Setup.hs patches modules = [{packages.darcs.patches = [ ./patches/darcs-setup.patch ];}]; }).components.exes.darcs; @@ -38,7 +39,7 @@ in rec { update-hackage = haskell.callPackage ./scripts/update-hackage.nix {}; update-stackage = haskell.callPackage ./scripts/update-stackage.nix {}; update-pins = haskell.callPackage ./scripts/update-pins.nix {}; - update-docs = haskell.callPackage ./scripts/update-docs.nix { + update-docs = pkgs.buildPackages.callPackage ./scripts/update-docs.nix { generatedOptions = import ./scripts/options-doc.nix { # nixpkgs unstable changes "Option has no description" from an # error into a warning. That is quite helpful when hardly any @@ -51,8 +52,10 @@ in rec { }) {}; }; }; - check-hydra = haskell.callPackage ./scripts/check-hydra.nix {}; - check-closure-size = haskell.callPackage ./scripts/check-closure-size.nix {}; + check-hydra = pkgs.buildPackages.callPackage ./scripts/check-hydra.nix {}; + check-closure-size = pkgs.buildPackages.callPackage ./scripts/check-closure-size.nix { + inherit (haskell) nix-tools; + }; }; # These are pure parts of maintainer-script so they can be built by hydra @@ -61,7 +64,7 @@ in rec { inherit (maintainer-scripts) update-docs check-hydra check-closure-size; # Some of the dependencies of the impure scripts so that they will # will be in the cache too for buildkite. - inherit (pkgs) coreutils glibc git openssh cabal-install nix-prefetch-git; + inherit (pkgs.buildPackages) glibc coreutils git openssh cabal-install nix-prefetch-git; inherit (haskell) nix-tools; }; } diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index bb255d94..b97e090d 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -174,7 +174,7 @@ let # project where the files haven't been added to the git # repo yet. We fail early and provide a useful error # message to prevent headaches (#290). - if [ -z "$(ls -A ${maybeCleanedSource})" ]; + if [ -z "$(ls -A ${maybeCleanedSource})" ]; then echo "cleaned source is empty. Did you forget to 'git add -A'?"; exit 1; fi cp -r ${maybeCleanedSource}/* . diff --git a/modules/package.nix b/modules/package.nix index 4cac6121..9b96f3e6 100644 --- a/modules/package.nix +++ b/modules/package.nix @@ -192,7 +192,7 @@ in { }; hsSourceDirs = mkOption { type = listOfFilteringNulls unspecified; - default = []; + default = ["."]; }; includeDirs = mkOption { type = listOfFilteringNulls unspecified; diff --git a/nixpkgs/github.json b/nixpkgs/github.json index 28e8e4b2..caed13f0 100644 --- a/nixpkgs/github.json +++ b/nixpkgs/github.json @@ -1,7 +1,7 @@ { "url": "https://github.com/input-output-hk/nixpkgs", - "rev": "3d623a406cec9052ae0a16a79ce3ce9de11236bb", - "date": "2019-10-18T17:51:24+13:00", - "sha256": "1a4yd980ylh1ygvmws15wldifz7jxjy8z07vc914kam1p25yjpj1", + "rev": "31aa5316ca232a53667790a99e8b1e76252e065c", + "date": "2019-11-16T23:51:02+13:00", + "sha256": "0g0r473rdrh5vsdvr45nmfs6ibp0pqyzbw9f0iv6r0jkg6jjiykr", "fetchSubmodules": false } diff --git a/nixpkgs/release-19.03.json b/nixpkgs/release-19.03.json index 2a89d187..3bfa561f 100644 --- a/nixpkgs/release-19.03.json +++ b/nixpkgs/release-19.03.json @@ -1,7 +1,7 @@ { - "url": "https://github.com/nixos/nixpkgs", - "rev": "49ac77d07eb9757244b776e35b9eb68d63943b12", - "date": "2019-07-30T15:46:41+02:00", - "sha256": "0xsmh17z5bl17dnpwf23m53a432651ylvk8qnjlmj43blxgiwrs5", + "url": "https://github.com/input-output-hk/nixpkgs", + "rev": "a8f81dc037a5977414a356dd068f2621b3c89b60", + "date": "2019-10-17T21:54:56+08:00", + "sha256": "01z13axll5g5yl00lz9adr2jw2bs12g9skhbb1vxy8p7fjjbhhhm", "fetchSubmodules": false } diff --git a/nixpkgs/release-19.09.json b/nixpkgs/release-19.09.json new file mode 100644 index 00000000..caed13f0 --- /dev/null +++ b/nixpkgs/release-19.09.json @@ -0,0 +1,7 @@ +{ + "url": "https://github.com/input-output-hk/nixpkgs", + "rev": "31aa5316ca232a53667790a99e8b1e76252e065c", + "date": "2019-11-16T23:51:02+13:00", + "sha256": "0g0r473rdrh5vsdvr45nmfs6ibp0pqyzbw9f0iv6r0jkg6jjiykr", + "fetchSubmodules": false +} diff --git a/overlays/haskell.nix b/overlays/haskell.nix index 299ea039..54f1b829 100644 --- a/overlays/haskell.nix +++ b/overlays/haskell.nix @@ -365,20 +365,23 @@ self: super: { inherit derivation; inputs = builtins.listToAttrs ( builtins.concatMap (i: if i == null then [] else [ - { name = builtins.replaceStrings ["."] ["_"] i.name; value = i; } + { name = builtins.replaceStrings ["." (self.stdenv.hostPlatform.config + "-")] ["_" ""] i.name; value = i; } ]) derivation.nativeBuildInputs); }; # Add this to your tests to make all the dependencies of haskell.nix # are tested and cached. haskellNixRoots = self.recurseIntoAttrs (builtins.mapAttrs (_: self.recurseIntoAttrs) { - inherit (self.haskell-nix) nix-tools source-pins; - bootstap-nix-tools = self.haskell-nix.bootstrap.packages.nix-tools; - alex-plan-nix = withInputs self.haskell-nix.bootstrap.packages.alex-project.plan-nix; - happy-plan-nix = withInputs self.haskell-nix.bootstrap.packages.happy-project.plan-nix; - hscolour-plan-nix = withInputs self.haskell-nix.bootstrap.packages.hscolour-project.plan-nix; + inherit (self.buildPackages.haskell-nix) nix-tools source-pins; + bootstap-nix-tools = self.buildPackages.haskell-nix.bootstrap.packages.nix-tools; + alex-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.alex-project.plan-nix; + happy-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.happy-project.plan-nix; + hscolour-plan-nix = withInputs self.buildPackages.haskell-nix.bootstrap.packages.hscolour-project.plan-nix; ghc-extra-projects = builtins.mapAttrs (_: proj: self.recurseIntoAttrs (withInputs proj.plan-nix)) - (self.lib.filterAttrs (n: _: n != "ghc844" && n != "ghc861" && n != "ghc862") self.ghc-extra-projects); + (self.lib.filterAttrs (n: _: n != "ghc844" && n != "ghc861" && n != "ghc862" + # There is an issue with GHC 8.6.4 and nixpkgs 19.09, so only build it for 19.03 for now + && (n != "ghc864" || super.lib.versions.majorMinor super.lib.version == "19.03") + ) self.ghc-extra-projects); }); }; } diff --git a/release.nix b/release.nix index 7895f669..6b75de73 100644 --- a/release.nix +++ b/release.nix @@ -4,13 +4,8 @@ , nixpkgsArgs ? {} }: -let fixedNixpkgs = import ./nixpkgs {}; in -with fixedNixpkgs.lib; -with (import (fixedNixpkgs.path + "/pkgs/top-level/release-lib.nix") { - inherit supportedSystems scrubJobs nixpkgsArgs; - packageSet = import (haskell-nix + /build.nix); -}); - +let defaultNixpkgs = import ./nixpkgs {}; in +with defaultNixpkgs.lib; let # Remove tests which have meta.disabled = true filterTests = let @@ -20,20 +15,49 @@ let tests = filterAttrs (_: nonEmpty) (mapAttrs (name: removeDisabled) jobs.tests); }; - inherit (systems.examples) musl64; + jobs = nixpkgs-pin: + # Now we know what nixpkgs-pin we are testing use that one. + # This fixes and issue where the vendor has changed from `x86_64-pc-mingw32` + # to `x86_64-w64-mingw32` in 19.09. + let pinnedNixpkgs = import ./nixpkgs { inherit nixpkgs-pin; }; in + with pinnedNixpkgs.lib; + let inherit (systems.examples) musl64 mingwW64; in + with (import (pinnedNixpkgs.path + "/pkgs/top-level/release-lib.nix") { + inherit supportedSystems scrubJobs nixpkgsArgs; + packageSet = { + system ? builtins.currentSystem + , crossSystem ? null + , nixpkgsArgs ? { inherit system crossSystem; } + , ...}@args: + import (haskell-nix + /build.nix) (args // { + nixpkgsArgs = nixpkgsArgs // { inherit nixpkgs-pin; }; + }); + }); - jobs = { - native = filterTests (mapTestOn (packagePlatforms pkgs)); - # Disabled for now. Something is wrong and this would require `allowBroken` - # "${musl64.config}" = filterTests (mapTestOnCross musl64 (packagePlatforms pkgs)); - } // { + { + native = filterTests (mapTestOn (packagePlatforms pkgs)); + # Disabled for now. Something is wrong and this would require `allowBroken` + # "${musl64.config}" = filterTests (mapTestOnCross musl64 (packagePlatforms pkgs)); + } // (optionalAttrs (nixpkgs-pin == "release-19.03") { + "${mingwW64.config}" = filterTests (mapTestOnCross mingwW64 (packagePlatforms pkgs)); + }); + + allJobs = + builtins.mapAttrs (_: nixpkgs-pin: jobs nixpkgs-pin) { + "R1903" = "release-19.03"; + "R1909" = "release-19.09"; + }; + +in allJobs // { # On IOHK Hydra, "required" is a special job that updates the # GitHub CI status. - required = fixedNixpkgs.releaseTools.aggregate { + required = defaultNixpkgs.releaseTools.aggregate { name = "haskell.nix-required"; meta.description = "All jobs required to pass CI"; - constituents = collect isDerivation jobs.native; + constituents = + collect isDerivation allJobs.R1903.native + ++ collect isDerivation allJobs.R1909.native; }; - }; + } + -in jobs diff --git a/test/buildable/default.nix b/test/buildable/default.nix index dabfece7..b7e703c4 100644 --- a/test/buildable/default.nix +++ b/test/buildable/default.nix @@ -1,28 +1,25 @@ -{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject }: +{ stdenv, cabalProject', haskellLib, recurseIntoAttrs }: with stdenv.lib; let - plan = importAndFilterProject (callCabalProjectToNix { + project = cabalProject' { name = "test-buildable"; index-state = "2019-04-30T00:00:00Z"; - src = ./.; - }); - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = plan.pkgs; + src = haskellLib.cleanGit { src = ../..; subDir = "test/buildable"; }; modules = [ { packages.buildable-test.flags.exclude-broken = true; } ]; }; - packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + packages = project.hsPkgs; + +in recurseIntoAttrs { + inherit (project) plan-nix; + run = stdenv.mkDerivation { name = "buildable-test"; buildCommand = (concatStrings (mapAttrsToList (name: value: '' - exe="${value}/bin/${name}" - printf "checking whether executable runs... " >& 2 - $exe + cat ${value.run} '') packages.buildable-test.components.exes)) + '' touch $out ''; @@ -31,7 +28,7 @@ in passthru = { # Attributes used for debugging with nix repl - inherit pkgSet packages; - inherit (plan) nix; + inherit project packages; }; - } + }; +} \ No newline at end of file diff --git a/test/builder-haddock/default.nix b/test/builder-haddock/default.nix index ffcdec8f..06211039 100644 --- a/test/builder-haddock/default.nix +++ b/test/builder-haddock/default.nix @@ -35,7 +35,12 @@ in buildCommand = let inherit (packages.test-haddock.components) library; noDocLibrary = packages.stm.components.library; - in '' + in if (stdenv.hostPlatform != stdenv.buildPlatform) + then '' + echo "Skipping haddock tests when cross compiling" >& 2 + touch $out + '' + else '' ######################################################################## # test haddock diff --git a/test/cabal-22/.plan.nix/project.nix b/test/cabal-22/.plan.nix/project.nix deleted file mode 100644 index 40bed71a..00000000 --- a/test/cabal-22/.plan.nix/project.nix +++ /dev/null @@ -1,94 +0,0 @@ -let - buildDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (build dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - sysDepError = pkg: - builtins.throw '' - The Nixpkgs package set does not contain the package: ${pkg} (system dependency). - - You may need to augment the system package mapping in haskell.nix so that it can be found. - ''; - pkgConfDepError = pkg: - builtins.throw '' - The pkg-conf packages does not contain the package: ${pkg} (pkg-conf dependency). - - You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found. - ''; - exeDepError = pkg: - builtins.throw '' - The local executable components do not include the component: ${pkg} (executable dependency). - ''; - legacyExeDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (executable dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - buildToolDepError = pkg: - builtins.throw '' - Neither the Haskell package set or the Nixpkgs package set contain the package: ${pkg} (build tool dependency). - - If this is a system dependency: - You may need to augment the system package mapping in haskell.nix so that it can be found. - - If this is a Haskell dependency: - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; -in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: - { - flags = {}; - package = { - specVersion = "2.2"; - identifier = { name = "project"; version = "0.1.0.0"; }; - license = "NONE"; - copyright = ""; - maintainer = "rodney.lorrimar@iohk.io"; - author = "Rodney Lorrimar"; - homepage = ""; - url = ""; - synopsis = ""; - description = ""; - buildType = "Simple"; - isLocal = true; - }; - components = { - "library" = { - depends = [ (hsPkgs."base" or (buildDepError "base")) ]; - buildable = true; - }; - exes = { - "project" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."project" or (buildDepError "project")) - ]; - buildable = true; - }; - }; - tests = { - "unit" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."project" or (buildDepError "project")) - (hsPkgs."hspec" or (buildDepError "hspec")) - ]; - build-tools = [ - (hsPkgs.buildPackages.hspec-discover or (pkgs.buildPackages.hspec-discover or (buildToolDepError "hspec-discover"))) - ]; - buildable = true; - }; - }; - benchmarks = { - "project-bench" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."project" or (buildDepError "project")) - ]; - buildable = true; - }; - }; - }; - } // rec { src = (pkgs.lib).mkDefault ../.; } \ No newline at end of file diff --git a/test/cabal-22/default.nix b/test/cabal-22/default.nix index 5daf694a..4e1a7d2d 100644 --- a/test/cabal-22/default.nix +++ b/test/cabal-22/default.nix @@ -1,20 +1,23 @@ -{ stdenv, mkCabalProjectPkgSet, util }: +{ stdenv, mkCabalProjectPkgSet, cabalProject', haskellLib, util, recurseIntoAttrs }: with stdenv.lib; let - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = import ./pkgs.nix; + project = cabalProject' { + name = "cabal-22"; + src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-22"; }; }; - packages = pkgSet.config.hsPkgs; + packages = project.hsPkgs; -in - stdenv.mkDerivation { +in recurseIntoAttrs { + inherit (project) plan-nix; + shell = util.addCabalInstall packages.project.components.all; + run = stdenv.mkDerivation { name = "cabal-22-test"; buildCommand = '' - exe="${packages.project.components.exes.project}/bin/project" + exe="${packages.project.components.exes.project}/bin/project${stdenv.hostPlatform.extensions.executable}" size=$(command stat --format '%s' "$exe") printf "size of executable $exe is $size. \n" >& 2 @@ -56,6 +59,6 @@ in meta.platforms = platforms.all; passthru = { inherit (packages) project; - shell = util.addCabalInstall packages.project.components.all; }; - } + }; +} \ No newline at end of file diff --git a/test/cabal-22/pkgs.nix b/test/cabal-22/pkgs.nix deleted file mode 100644 index d44a9ab0..00000000 --- a/test/cabal-22/pkgs.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ - pkgs = hackage: - { - packages = { - "tf-random".revision = (((hackage."tf-random")."0.5").revisions).default; - "ghc-prim".revision = (((hackage."ghc-prim")."0.5.3").revisions).default; - "stm".revision = (((hackage."stm")."2.5.0.0").revisions).default; - "unix".revision = (((hackage."unix")."2.7.2.2").revisions).default; - "rts".revision = (((hackage."rts")."1.0").revisions).default; - "clock".revision = (((hackage."clock")."0.8").revisions).default; - "clock".flags.llvm = false; - "QuickCheck".revision = (((hackage."QuickCheck")."2.13.2").revisions).default; - "QuickCheck".flags.templatehaskell = true; - "hspec-discover".revision = (((hackage."hspec-discover")."2.7.1").revisions).default; - "deepseq".revision = (((hackage."deepseq")."1.4.4.0").revisions).default; - "random".revision = (((hackage."random")."1.1").revisions).default; - "splitmix".revision = (((hackage."splitmix")."0.0.3").revisions).default; - "splitmix".flags.optimised-mixer = false; - "splitmix".flags.random = true; - "HUnit".revision = (((hackage."HUnit")."1.6.0.0").revisions).default; - "directory".revision = (((hackage."directory")."1.3.3.0").revisions).default; - "template-haskell".revision = (((hackage."template-haskell")."2.14.0.0").revisions).default; - "hspec-expectations".revision = (((hackage."hspec-expectations")."0.8.2").revisions).default; - "call-stack".revision = (((hackage."call-stack")."0.2.0").revisions).default; - "primitive".revision = (((hackage."primitive")."0.7.0.0").revisions).default; - "ansi-terminal".revision = (((hackage."ansi-terminal")."0.10.1").revisions).default; - "ansi-terminal".flags.example = false; - "containers".revision = (((hackage."containers")."0.6.0.1").revisions).default; - "bytestring".revision = (((hackage."bytestring")."0.10.8.2").revisions).default; - "setenv".revision = (((hackage."setenv")."0.1.1.3").revisions).default; - "base".revision = (((hackage."base")."4.12.0.0").revisions).default; - "hspec".revision = (((hackage."hspec")."2.7.1").revisions).default; - "time".revision = (((hackage."time")."1.8.0.2").revisions).default; - "transformers".revision = (((hackage."transformers")."0.5.6.2").revisions).default; - "quickcheck-io".revision = (((hackage."quickcheck-io")."0.2.0").revisions).default; - "colour".revision = (((hackage."colour")."2.3.5").revisions).default; - "filepath".revision = (((hackage."filepath")."1.4.2.1").revisions).default; - "hspec-core".revision = (((hackage."hspec-core")."2.7.1").revisions).default; - "pretty".revision = (((hackage."pretty")."1.1.3.6").revisions).default; - "ghc-boot-th".revision = (((hackage."ghc-boot-th")."8.6.5").revisions).default; - "array".revision = (((hackage."array")."0.5.3.0").revisions).default; - "integer-gmp".revision = (((hackage."integer-gmp")."1.0.2.0").revisions).default; - }; - compiler = { - version = "8.6.5"; - nix-name = "ghc865"; - packages = { - "ghc-prim" = "0.5.3"; - "stm" = "2.5.0.0"; - "unix" = "2.7.2.2"; - "rts" = "1.0"; - "deepseq" = "1.4.4.0"; - "directory" = "1.3.3.0"; - "template-haskell" = "2.14.0.0"; - "containers" = "0.6.0.1"; - "bytestring" = "0.10.8.2"; - "base" = "4.12.0.0"; - "time" = "1.8.0.2"; - "transformers" = "0.5.6.2"; - "filepath" = "1.4.2.1"; - "pretty" = "1.1.3.6"; - "ghc-boot-th" = "8.6.5"; - "array" = "0.5.3.0"; - "integer-gmp" = "1.0.2.0"; - }; - }; - }; - extras = hackage: - { packages = { project = ./.plan.nix/project.nix; }; }; - modules = [ - ({ lib, ... }: - { packages = { "project" = { flags = {}; }; }; }) - ]; - } \ No newline at end of file diff --git a/test/cabal-22/project.nix b/test/cabal-22/project.nix deleted file mode 100644 index 6baf51ba..00000000 --- a/test/cabal-22/project.nix +++ /dev/null @@ -1,93 +0,0 @@ -let - buildDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (build dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - sysDepError = pkg: - builtins.throw '' - The Nixpkgs package set does not contain the package: ${pkg} (system dependency). - - You may need to augment the system package mapping in haskell.nix so that it can be found. - ''; - pkgConfDepError = pkg: - builtins.throw '' - The pkg-conf packages does not contain the package: ${pkg} (pkg-conf dependency). - - You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found. - ''; - exeDepError = pkg: - builtins.throw '' - The local executable components do not include the component: ${pkg} (executable dependency). - ''; - legacyExeDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (executable dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - buildToolDepError = pkg: - builtins.throw '' - Neither the Haskell package set or the Nixpkgs package set contain the package: ${pkg} (build tool dependency). - - If this is a system dependency: - You may need to augment the system package mapping in haskell.nix so that it can be found. - - If this is a Haskell dependency: - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; -in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: - { - flags = {}; - package = { - specVersion = "2.2"; - identifier = { name = "project"; version = "0.1.0.0"; }; - license = "NONE"; - copyright = ""; - maintainer = "rodney.lorrimar@iohk.io"; - author = "Rodney Lorrimar"; - homepage = ""; - url = ""; - synopsis = ""; - description = ""; - buildType = "Simple"; - }; - components = { - "library" = { - depends = [ (hsPkgs."base" or (buildDepError "base")) ]; - buildable = true; - }; - exes = { - "project" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."project" or (buildDepError "project")) - ]; - buildable = true; - }; - }; - tests = { - "unit" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."project" or (buildDepError "project")) - (hsPkgs."hspec" or (buildDepError "hspec")) - ]; - build-tools = [ - (hsPkgs.buildPackages.hspec-discover or (pkgs.buildPackages.hspec-discover or (buildToolDepError "hspec-discover"))) - ]; - buildable = true; - }; - }; - benchmarks = { - "project-bench" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."project" or (buildDepError "project")) - ]; - buildable = true; - }; - }; - }; - } // rec { src = (pkgs.lib).mkDefault ./.; } diff --git a/test/cabal-simple-prof/.plan.nix/cabal-simple.nix b/test/cabal-simple-prof/.plan.nix/cabal-simple.nix deleted file mode 100644 index bb2704f8..00000000 --- a/test/cabal-simple-prof/.plan.nix/cabal-simple.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: - { - flags = {}; - package = { - specVersion = "1.10"; - identifier = { name = "cabal-simple"; version = "0.1.0.0"; }; - license = "LicenseRef-PublicDomain"; - copyright = ""; - maintainer = "rodney.lorrimar@iohk.io"; - author = "Rodney Lorrimar"; - homepage = ""; - url = ""; - synopsis = ""; - description = ""; - buildType = "Simple"; - }; - components = { - "library" = { - depends = [ (hsPkgs.base) (hsPkgs.extra) (hsPkgs.safe) (hsPkgs.aeson) ]; - }; - exes = { - "cabal-simple" = { - depends = [ - (hsPkgs.base) - (hsPkgs.cabal-simple) - (hsPkgs.extra) - (hsPkgs.optparse-applicative) - ]; - }; - }; - }; - } // rec { src = (pkgs.lib).mkDefault ../.; } \ No newline at end of file diff --git a/test/cabal-simple-prof/default.nix b/test/cabal-simple-prof/default.nix index 14c5b3bf..39c03c84 100644 --- a/test/cabal-simple-prof/default.nix +++ b/test/cabal-simple-prof/default.nix @@ -1,38 +1,42 @@ # Test a package set -{ stdenv, util, mkCabalProjectPkgSet }: +{ stdenv, util, cabalProject', haskellLib, recurseIntoAttrs }: with stdenv.lib; let - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = import ./pkgs.nix; - modules = [ - { - # Package has no exposed modules which causes - # haddock: No input file(s) - packages.cabal-simple.doHaddock = false; - packages.cabal-simple.enableExecutableProfiling = true; - enableLibraryProfiling = true; - # executableProfiling = false; - } - ]; + modules = [ + { + # Package has no exposed modules which causes + # haddock: No input file(s) + packages.cabal-simple.doHaddock = false; + packages.cabal-simple.enableExecutableProfiling = true; + enableLibraryProfiling = true; + # executableProfiling = false; + } + ]; + + project = cabalProject' { + name = "cabal-simple-prof"; + src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-simple-prof"; }; + inherit modules; }; - packages = pkgSet.config.hsPkgs; + packages = project.hsPkgs; -in - stdenv.mkDerivation { +in recurseIntoAttrs { + inherit (project) plan-nix; + run = stdenv.mkDerivation { name = "cabal-simple-prof-test"; buildCommand = '' - exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple" + exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}" size=$(command stat --format '%s' "$exe") printf "size of executable $exe is $size. \n" >& 2 # fixme: run on target platform when cross-compiled printf "checking whether executable runs with profiling... " >& 2 - $exe +RTS -p -h + ${toString packages.cabal-simple.components.exes.cabal-simple.config.testWrapper} $exe +RTS -p -h touch $out ''; @@ -41,10 +45,11 @@ in passthru = { # Used for debugging with nix repl - inherit pkgSet packages; + inherit project packages; # Used for testing externally with nix-shell (../tests.sh). # This just adds cabal-install to the existing shells. test-shell = util.addCabalInstall packages.cabal-simple.components.all; }; + }; } diff --git a/test/cabal-simple-prof/pkgs.nix b/test/cabal-simple-prof/pkgs.nix deleted file mode 100644 index 73e53525..00000000 --- a/test/cabal-simple-prof/pkgs.nix +++ /dev/null @@ -1,124 +0,0 @@ -{ - pkgs = hackage: - { - packages = { - "binary".revision = (((hackage."binary")."0.8.5.1").revisions).default; - "ghc-prim".revision = (((hackage."ghc-prim")."0.5.2.0").revisions).default; - "extra".revision = (((hackage."extra")."1.6.15").revisions).default; - "stm".revision = (((hackage."stm")."2.4.5.1").revisions).default; - "unix".revision = (((hackage."unix")."2.7.2.2").revisions).default; - "rts".revision = (((hackage."rts")."1.0").revisions).default; - "clock".revision = (((hackage."clock")."0.8").revisions).default; - "clock".flags.llvm = false; - "scientific".revision = (((hackage."scientific")."0.3.6.2").revisions).default; - "scientific".flags.integer-simple = false; - "scientific".flags.bytestring-builder = false; - "deepseq".revision = (((hackage."deepseq")."1.4.3.0").revisions).default; - "random".revision = (((hackage."random")."1.1").revisions).default; - "uuid-types".revision = (((hackage."uuid-types")."1.0.3").revisions).default; - "optparse-applicative".revision = (((hackage."optparse-applicative")."0.14.3.0").revisions).default; - "dlist".revision = (((hackage."dlist")."0.8.0.6").revisions).default; - "semigroups".revision = (((hackage."semigroups")."0.19").revisions).default; - "semigroups".flags.bytestring = true; - "semigroups".flags.unordered-containers = true; - "semigroups".flags.text = true; - "semigroups".flags.tagged = true; - "semigroups".flags.containers = true; - "semigroups".flags.binary = true; - "semigroups".flags.hashable = true; - "semigroups".flags.transformers = true; - "semigroups".flags.deepseq = true; - "semigroups".flags.bytestring-builder = false; - "semigroups".flags.template-haskell = true; - "directory".revision = (((hackage."directory")."1.3.1.5").revisions).default; - "transformers-compat".revision = (((hackage."transformers-compat")."0.6.5").revisions).default; - "transformers-compat".flags.five = false; - "transformers-compat".flags.generic-deriving = true; - "transformers-compat".flags.two = false; - "transformers-compat".flags.five-three = true; - "transformers-compat".flags.mtl = true; - "transformers-compat".flags.four = false; - "transformers-compat".flags.three = false; - "template-haskell".revision = (((hackage."template-haskell")."2.13.0.0").revisions).default; - "vector".revision = (((hackage."vector")."0.12.0.3").revisions).default; - "vector".flags.unsafechecks = false; - "vector".flags.internalchecks = false; - "vector".flags.wall = false; - "vector".flags.boundschecks = true; - "primitive".revision = (((hackage."primitive")."0.6.4.0").revisions).default; - "time-locale-compat".revision = (((hackage."time-locale-compat")."0.1.1.5").revisions).default; - "time-locale-compat".flags.old-locale = false; - "safe".revision = (((hackage."safe")."0.3.17").revisions).default; - "base-compat".revision = (((hackage."base-compat")."0.10.5").revisions).default; - "ansi-terminal".revision = (((hackage."ansi-terminal")."0.9.1").revisions).default; - "ansi-terminal".flags.example = false; - "tagged".revision = (((hackage."tagged")."0.8.6").revisions).default; - "tagged".flags.transformers = true; - "tagged".flags.deepseq = true; - "containers".revision = (((hackage."containers")."0.5.11.0").revisions).default; - "integer-logarithms".revision = (((hackage."integer-logarithms")."1.0.3").revisions).default; - "integer-logarithms".flags.check-bounds = false; - "integer-logarithms".flags.integer-gmp = true; - "bytestring".revision = (((hackage."bytestring")."0.10.8.2").revisions).default; - "ansi-wl-pprint".revision = (((hackage."ansi-wl-pprint")."0.6.9").revisions).default; - "ansi-wl-pprint".flags.example = false; - "StateVar".revision = (((hackage."StateVar")."1.1.1.1").revisions).default; - "contravariant".revision = (((hackage."contravariant")."1.5.1").revisions).default; - "contravariant".flags.semigroups = true; - "contravariant".flags.tagged = true; - "contravariant".flags.statevar = true; - "text".revision = (((hackage."text")."1.2.3.1").revisions).default; - "unordered-containers".revision = (((hackage."unordered-containers")."0.2.10.0").revisions).default; - "unordered-containers".flags.debug = false; - "base".revision = (((hackage."base")."4.11.1.0").revisions).default; - "time".revision = (((hackage."time")."1.8.0.2").revisions).default; - "transformers".revision = (((hackage."transformers")."0.5.6.2").revisions).default; - "hashable".revision = (((hackage."hashable")."1.2.7.0").revisions).default; - "hashable".flags.sse2 = true; - "hashable".flags.integer-gmp = true; - "hashable".flags.sse41 = false; - "hashable".flags.examples = false; - "attoparsec".revision = (((hackage."attoparsec")."0.13.2.2").revisions).default; - "attoparsec".flags.developer = false; - "colour".revision = (((hackage."colour")."2.3.5").revisions).default; - "filepath".revision = (((hackage."filepath")."1.4.2").revisions).default; - "process".revision = (((hackage."process")."1.6.5.0").revisions).default; - "pretty".revision = (((hackage."pretty")."1.1.3.6").revisions).default; - "aeson".revision = (((hackage."aeson")."1.4.3.0").revisions).default; - "aeson".flags.cffi = false; - "aeson".flags.fast = false; - "aeson".flags.bytestring-builder = false; - "aeson".flags.developer = false; - "ghc-boot-th".revision = (((hackage."ghc-boot-th")."8.4.4").revisions).default; - "th-abstraction".revision = (((hackage."th-abstraction")."0.3.1.0").revisions).default; - "array".revision = (((hackage."array")."0.5.2.0").revisions).default; - "integer-gmp".revision = (((hackage."integer-gmp")."1.0.2.0").revisions).default; - }; - compiler = { - version = "8.4.4"; - nix-name = "ghc844"; - packages = { - "binary" = "0.8.5.1"; - "ghc-prim" = "0.5.2.0"; - "stm" = "2.4.5.1"; - "unix" = "2.7.2.2"; - "rts" = "1.0"; - "deepseq" = "1.4.3.0"; - "directory" = "1.3.1.5"; - "template-haskell" = "2.13.0.0"; - "containers" = "0.5.11.0"; - "bytestring" = "0.10.8.2"; - "text" = "1.2.3.1"; - "base" = "4.11.1.0"; - "time" = "1.8.0.2"; - "filepath" = "1.4.2"; - "pretty" = "1.1.3.6"; - "ghc-boot-th" = "8.4.4"; - "array" = "0.5.2.0"; - "integer-gmp" = "1.0.2.0"; - }; - }; - }; - extras = hackage: - { packages = { cabal-simple = ./.plan.nix/cabal-simple.nix; }; }; - } \ No newline at end of file diff --git a/test/cabal-simple/.plan.nix/cabal-simple.nix b/test/cabal-simple/.plan.nix/cabal-simple.nix deleted file mode 100644 index 4be2add9..00000000 --- a/test/cabal-simple/.plan.nix/cabal-simple.nix +++ /dev/null @@ -1,79 +0,0 @@ -let - buildDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (build dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - sysDepError = pkg: - builtins.throw '' - The Nixpkgs package set does not contain the package: ${pkg} (system dependency). - - You may need to augment the system package mapping in haskell.nix so that it can be found. - ''; - pkgConfDepError = pkg: - builtins.throw '' - The pkg-conf packages does not contain the package: ${pkg} (pkg-conf dependency). - - You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found. - ''; - exeDepError = pkg: - builtins.throw '' - The local executable components do not include the component: ${pkg} (executable dependency). - ''; - legacyExeDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (executable dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - buildToolDepError = pkg: - builtins.throw '' - Neither the Haskell package set or the Nixpkgs package set contain the package: ${pkg} (build tool dependency). - - If this is a system dependency: - You may need to augment the system package mapping in haskell.nix so that it can be found. - - If this is a Haskell dependency: - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; -in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: - { - flags = {}; - package = { - specVersion = "1.10"; - identifier = { name = "cabal-simple"; version = "0.1.0.0"; }; - license = "LicenseRef-PublicDomain"; - copyright = ""; - maintainer = "rodney.lorrimar@iohk.io"; - author = "Rodney Lorrimar"; - homepage = ""; - url = ""; - synopsis = ""; - description = ""; - buildType = "Simple"; - isLocal = true; - }; - components = { - "library" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."extra" or (buildDepError "extra")) - (hsPkgs."safe" or (buildDepError "safe")) - (hsPkgs."aeson" or (buildDepError "aeson")) - ]; - buildable = true; - }; - exes = { - "cabal-simple" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."cabal-simple" or (buildDepError "cabal-simple")) - (hsPkgs."extra" or (buildDepError "extra")) - (hsPkgs."optparse-applicative" or (buildDepError "optparse-applicative")) - ]; - buildable = true; - }; - }; - }; - } // rec { src = (pkgs.lib).mkDefault ../.; } \ No newline at end of file diff --git a/test/cabal-simple/default.nix b/test/cabal-simple/default.nix index 112f4485..deaa452e 100644 --- a/test/cabal-simple/default.nix +++ b/test/cabal-simple/default.nix @@ -1,12 +1,10 @@ # Test a package set -{ stdenv, util, mkCabalProjectPkgSet, gmp6, zlib }: +{ stdenv, util, mkCabalProjectPkgSet, cabalProject', haskellLib, gmp6, zlib, recurseIntoAttrs }: with stdenv.lib; let - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = import ./pkgs.nix; - modules = [ + modules = [ { # Package has no exposed modules which causes # haddock: No input file(s) @@ -25,24 +23,35 @@ let # "--ghc-option=-optl=-L${zlib.static}/lib" ]; } - ]; + ]; + + project = cabalProject' { + name = "cabal-simple"; + src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-simple"; }; + inherit modules; }; - packages = pkgSet.config.hsPkgs; + packages = project.hsPkgs; -in - stdenv.mkDerivation { +in recurseIntoAttrs { + inherit (project) plan-nix; + + # Used for testing externally with nix-shell (../tests.sh). + # This just adds cabal-install to the existing shells. + test-shell = util.addCabalInstall packages.cabal-simple.components.all; + + run = stdenv.mkDerivation { name = "cabal-simple-test"; buildCommand = '' - exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple" + exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}" size=$(command stat --format '%s' "$exe") printf "size of executable $exe is $size. \n" >& 2 # fixme: run on target platform when cross-compiled printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.cabal-simple.components.exes.cabal-simple.run} '' + (if stdenv.hostPlatform.isMusl then '' printf "checking that executable is statically linked... " >& 2 (ldd $exe 2>&1 || true) | grep -i "not a" @@ -55,7 +64,7 @@ in '') + '' printf "Checking that \"all\" component has the programs... " >& 2 - all_exe="${packages.cabal-simple.components.all}/bin/cabal-simple" + all_exe="${packages.cabal-simple.components.all}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}" test -f "$all_exe" echo "$all_exe" >& 2 @@ -66,10 +75,7 @@ in passthru = { # Used for debugging with nix repl - inherit pkgSet packages; - - # Used for testing externally with nix-shell (../tests.sh). - # This just adds cabal-install to the existing shells. - test-shell = util.addCabalInstall packages.cabal-simple.components.all; + inherit project packages; }; + }; } diff --git a/test/cabal-simple/pkgs.nix b/test/cabal-simple/pkgs.nix deleted file mode 100644 index 101677d0..00000000 --- a/test/cabal-simple/pkgs.nix +++ /dev/null @@ -1,124 +0,0 @@ -{ - pkgs = hackage: - { - packages = { - "binary".revision = (((hackage."binary")."0.8.6.0").revisions).default; - "ghc-prim".revision = (((hackage."ghc-prim")."0.5.3").revisions).default; - "extra".revision = (((hackage."extra")."1.6.18").revisions).default; - "unix".revision = (((hackage."unix")."2.7.2.2").revisions).default; - "rts".revision = (((hackage."rts")."1.0").revisions).default; - "clock".revision = (((hackage."clock")."0.8").revisions).default; - "clock".flags.llvm = false; - "scientific".revision = (((hackage."scientific")."0.3.6.2").revisions).default; - "scientific".flags.integer-simple = false; - "scientific".flags.bytestring-builder = false; - "deepseq".revision = (((hackage."deepseq")."1.4.4.0").revisions).default; - "random".revision = (((hackage."random")."1.1").revisions).default; - "uuid-types".revision = (((hackage."uuid-types")."1.0.3").revisions).default; - "optparse-applicative".revision = (((hackage."optparse-applicative")."0.15.1.0").revisions).default; - "dlist".revision = (((hackage."dlist")."0.8.0.7").revisions).default; - "semigroups".revision = (((hackage."semigroups")."0.19.1").revisions).default; - "semigroups".flags.bytestring = true; - "semigroups".flags.unordered-containers = true; - "semigroups".flags.text = true; - "semigroups".flags.tagged = true; - "semigroups".flags.containers = true; - "semigroups".flags.binary = true; - "semigroups".flags.hashable = true; - "semigroups".flags.transformers = true; - "semigroups".flags.deepseq = true; - "semigroups".flags.bytestring-builder = false; - "semigroups".flags.template-haskell = true; - "directory".revision = (((hackage."directory")."1.3.3.0").revisions).default; - "transformers-compat".revision = (((hackage."transformers-compat")."0.6.5").revisions).default; - "transformers-compat".flags.five = false; - "transformers-compat".flags.generic-deriving = true; - "transformers-compat".flags.two = false; - "transformers-compat".flags.five-three = true; - "transformers-compat".flags.mtl = true; - "transformers-compat".flags.four = false; - "transformers-compat".flags.three = false; - "template-haskell".revision = (((hackage."template-haskell")."2.14.0.0").revisions).default; - "vector".revision = (((hackage."vector")."0.12.0.3").revisions).default; - "vector".flags.unsafechecks = false; - "vector".flags.internalchecks = false; - "vector".flags.wall = false; - "vector".flags.boundschecks = true; - "primitive".revision = (((hackage."primitive")."0.7.0.0").revisions).default; - "safe".revision = (((hackage."safe")."0.3.17").revisions).default; - "base-compat".revision = (((hackage."base-compat")."0.11.0").revisions).default; - "time-compat".revision = (((hackage."time-compat")."1.9.2.2").revisions).default; - "time-compat".flags.old-locale = false; - "ansi-terminal".revision = (((hackage."ansi-terminal")."0.10.1").revisions).default; - "ansi-terminal".flags.example = false; - "tagged".revision = (((hackage."tagged")."0.8.6").revisions).default; - "tagged".flags.transformers = true; - "tagged".flags.deepseq = true; - "containers".revision = (((hackage."containers")."0.6.0.1").revisions).default; - "integer-logarithms".revision = (((hackage."integer-logarithms")."1.0.3").revisions).default; - "integer-logarithms".flags.check-bounds = false; - "integer-logarithms".flags.integer-gmp = true; - "bytestring".revision = (((hackage."bytestring")."0.10.8.2").revisions).default; - "ansi-wl-pprint".revision = (((hackage."ansi-wl-pprint")."0.6.9").revisions).default; - "ansi-wl-pprint".flags.example = false; - "text".revision = (((hackage."text")."1.2.3.1").revisions).default; - "unordered-containers".revision = (((hackage."unordered-containers")."0.2.10.0").revisions).default; - "unordered-containers".flags.debug = false; - "base".revision = (((hackage."base")."4.12.0.0").revisions).default; - "time".revision = (((hackage."time")."1.8.0.2").revisions).default; - "transformers".revision = (((hackage."transformers")."0.5.6.2").revisions).default; - "hashable".revision = (((hackage."hashable")."1.3.0.0").revisions).default; - "hashable".flags.sse2 = true; - "hashable".flags.integer-gmp = true; - "hashable".flags.sse41 = false; - "hashable".flags.examples = false; - "attoparsec".revision = (((hackage."attoparsec")."0.13.2.3").revisions).default; - "attoparsec".flags.developer = false; - "colour".revision = (((hackage."colour")."2.3.5").revisions).default; - "filepath".revision = (((hackage."filepath")."1.4.2.1").revisions).default; - "process".revision = (((hackage."process")."1.6.5.0").revisions).default; - "pretty".revision = (((hackage."pretty")."1.1.3.6").revisions).default; - "aeson".revision = (((hackage."aeson")."1.4.5.0").revisions).default; - "aeson".flags.cffi = false; - "aeson".flags.fast = false; - "aeson".flags.bytestring-builder = false; - "aeson".flags.developer = false; - "ghc-boot-th".revision = (((hackage."ghc-boot-th")."8.6.5").revisions).default; - "base-orphans".revision = (((hackage."base-orphans")."0.8.1").revisions).default; - "th-abstraction".revision = (((hackage."th-abstraction")."0.3.1.0").revisions).default; - "array".revision = (((hackage."array")."0.5.3.0").revisions).default; - "integer-gmp".revision = (((hackage."integer-gmp")."1.0.2.0").revisions).default; - }; - compiler = { - version = "8.6.5"; - nix-name = "ghc865"; - packages = { - "binary" = "0.8.6.0"; - "ghc-prim" = "0.5.3"; - "unix" = "2.7.2.2"; - "rts" = "1.0"; - "deepseq" = "1.4.4.0"; - "directory" = "1.3.3.0"; - "template-haskell" = "2.14.0.0"; - "containers" = "0.6.0.1"; - "bytestring" = "0.10.8.2"; - "text" = "1.2.3.1"; - "base" = "4.12.0.0"; - "time" = "1.8.0.2"; - "transformers" = "0.5.6.2"; - "filepath" = "1.4.2.1"; - "process" = "1.6.5.0"; - "pretty" = "1.1.3.6"; - "ghc-boot-th" = "8.6.5"; - "array" = "0.5.3.0"; - "integer-gmp" = "1.0.2.0"; - }; - }; - }; - extras = hackage: - { packages = { cabal-simple = ./.plan.nix/cabal-simple.nix; }; }; - modules = [ - ({ lib, ... }: - { packages = { "cabal-simple" = { flags = {}; }; }; }) - ]; - } \ No newline at end of file diff --git a/test/cabal-source-repo/default.nix b/test/cabal-source-repo/default.nix index 229d27b4..14d97e4c 100644 --- a/test/cabal-source-repo/default.nix +++ b/test/cabal-source-repo/default.nix @@ -1,26 +1,24 @@ -{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject }: +{ stdenv, cabalProject', recurseIntoAttrs }: with stdenv.lib; let - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = (importAndFilterProject (callCabalProjectToNix { - name = "test-cabal-source-repo"; - index-state = "2019-04-30T00:00:00Z"; - # reuse the cabal-simple test project - src = ./.; - })).pkgs; + project = cabalProject' { + name = "test-cabal-source-repo"; + index-state = "2019-04-30T00:00:00Z"; + src = ./.; }; - packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + packages = project.hsPkgs; +in recurseIntoAttrs { + inherit (project) plan-nix; + run = stdenv.mkDerivation { name = "call-cabal-project-to-nix-test"; buildCommand = '' - exe="${packages.use-cabal-simple.components.exes.use-cabal-simple}/bin/use-cabal-simple" + exe="${packages.use-cabal-simple.components.exes.use-cabal-simple}/bin/use-cabal-simple${stdenv.hostPlatform.extensions.executable}" printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.use-cabal-simple.components.exes.use-cabal-simple.run} touch $out ''; @@ -31,4 +29,5 @@ in # Attributes used for debugging with nix repl inherit pkgSet packages; }; - } + }; +} \ No newline at end of file diff --git a/test/cabal-sublib/.plan.nix/cabal-sublib.nix b/test/cabal-sublib/.plan.nix/cabal-sublib.nix deleted file mode 100644 index e40093f3..00000000 --- a/test/cabal-sublib/.plan.nix/cabal-sublib.nix +++ /dev/null @@ -1,87 +0,0 @@ -let - buildDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (build dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - sysDepError = pkg: - builtins.throw '' - The Nixpkgs package set does not contain the package: ${pkg} (system dependency). - - You may need to augment the system package mapping in haskell.nix so that it can be found. - ''; - pkgConfDepError = pkg: - builtins.throw '' - The pkg-conf packages does not contain the package: ${pkg} (pkg-conf dependency). - - You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found. - ''; - exeDepError = pkg: - builtins.throw '' - The local executable components do not include the component: ${pkg} (executable dependency). - ''; - legacyExeDepError = pkg: - builtins.throw '' - The Haskell package set does not contain the package: ${pkg} (executable dependency). - - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; - buildToolDepError = pkg: - builtins.throw '' - Neither the Haskell package set or the Nixpkgs package set contain the package: ${pkg} (build tool dependency). - - If this is a system dependency: - You may need to augment the system package mapping in haskell.nix so that it can be found. - - If this is a Haskell dependency: - If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix. - ''; -in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: - { - flags = {}; - package = { - specVersion = "2.2"; - identifier = { name = "cabal-sublib"; version = "0.1.0.0"; }; - license = "MIT"; - copyright = ""; - maintainer = "moritz.angermann@iohk.io"; - author = "Moritz Angermann"; - homepage = ""; - url = ""; - synopsis = ""; - description = ""; - buildType = "Simple"; - isLocal = true; - }; - components = { - "library" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."slib" or (buildDepError "slib")) - ]; - buildable = true; - }; - sublibs = { - "slib" = { - depends = [ - (hsPkgs."extra" or (buildDepError "extra")) - (hsPkgs."safe" or (buildDepError "safe")) - (hsPkgs."aeson" or (buildDepError "aeson")) - ]; - buildable = true; - }; - }; - exes = { - "cabal-sublib" = { - depends = [ - (hsPkgs."base" or (buildDepError "base")) - (hsPkgs."cabal-sublib" or (buildDepError "cabal-sublib")) - (hsPkgs."extra" or (buildDepError "extra")) - (hsPkgs."optparse-applicative" or (buildDepError "optparse-applicative")) - ]; - buildable = true; - }; - }; - }; - } // rec { src = (pkgs.lib).mkDefault ../.; } \ No newline at end of file diff --git a/test/cabal-sublib/default.nix b/test/cabal-sublib/default.nix index 0fad746c..7b2fa798 100644 --- a/test/cabal-sublib/default.nix +++ b/test/cabal-sublib/default.nix @@ -1,35 +1,40 @@ # Test a package set -{ stdenv, util, mkCabalProjectPkgSet }: +{ stdenv, util, cabalProject', haskellLib, recurseIntoAttrs }: with stdenv.lib; let - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = import ./pkgs.nix; - modules = [ - { - # Package has no exposed modules which causes - # haddock: No input file(s) - packages.cabal-sublib.doHaddock = false; - } - ]; + modules = [ + { + # Package has no exposed modules which causes + # haddock: No input file(s) + packages.cabal-sublib.doHaddock = false; + } + ]; + + # The ./pkgs.nix works for linux & darwin, but not for windows + project = cabalProject' { + name = "cabal-sublib"; + src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-sublib"; }; + inherit modules; }; - packages = pkgSet.config.hsPkgs; + packages = project.hsPkgs; -in - stdenv.mkDerivation { +in recurseIntoAttrs { + inherit (project) plan-nix; + run = stdenv.mkDerivation { name = "cabal-sublib-test"; buildCommand = '' - exe="${packages.cabal-sublib.components.exes.cabal-sublib}/bin/cabal-sublib" + exe="${packages.cabal-sublib.components.exes.cabal-sublib}/bin/cabal-sublib${stdenv.hostPlatform.extensions.executable}" size=$(command stat --format '%s' "$exe") printf "size of executable $exe is $size. \n" >& 2 # fixme: run on target platform when cross-compiled printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.cabal-sublib.components.exes.cabal-sublib.run} printf "checking that executable is dynamically linked to system libraries... " >& 2 '' + optionalString stdenv.isLinux '' @@ -39,7 +44,7 @@ in '' + '' printf "Checking that \"all\" component has the programs... " >& 2 - all_exe="${packages.cabal-sublib.components.all}/bin/cabal-sublib" + all_exe="${packages.cabal-sublib.components.all}/bin/cabal-sublib${stdenv.hostPlatform.extensions.executable}" test -f "$all_exe" echo "$all_exe" >& 2 @@ -56,4 +61,5 @@ in # This just adds cabal-install to the existing shells. test-shell = util.addCabalInstall packages.cabal-sublib.components.all; }; + }; } diff --git a/test/cabal-sublib/pkgs.nix b/test/cabal-sublib/pkgs.nix deleted file mode 100644 index cf3be212..00000000 --- a/test/cabal-sublib/pkgs.nix +++ /dev/null @@ -1,124 +0,0 @@ -{ - pkgs = hackage: - { - packages = { - "binary".revision = (((hackage."binary")."0.8.6.0").revisions).default; - "ghc-prim".revision = (((hackage."ghc-prim")."0.5.3").revisions).default; - "extra".revision = (((hackage."extra")."1.6.18").revisions).default; - "unix".revision = (((hackage."unix")."2.7.2.2").revisions).default; - "rts".revision = (((hackage."rts")."1.0").revisions).default; - "clock".revision = (((hackage."clock")."0.8").revisions).default; - "clock".flags.llvm = false; - "scientific".revision = (((hackage."scientific")."0.3.6.2").revisions).default; - "scientific".flags.integer-simple = false; - "scientific".flags.bytestring-builder = false; - "deepseq".revision = (((hackage."deepseq")."1.4.4.0").revisions).default; - "random".revision = (((hackage."random")."1.1").revisions).default; - "uuid-types".revision = (((hackage."uuid-types")."1.0.3").revisions).default; - "optparse-applicative".revision = (((hackage."optparse-applicative")."0.15.1.0").revisions).default; - "dlist".revision = (((hackage."dlist")."0.8.0.7").revisions).default; - "semigroups".revision = (((hackage."semigroups")."0.19.1").revisions).default; - "semigroups".flags.bytestring = true; - "semigroups".flags.unordered-containers = true; - "semigroups".flags.text = true; - "semigroups".flags.tagged = true; - "semigroups".flags.containers = true; - "semigroups".flags.binary = true; - "semigroups".flags.hashable = true; - "semigroups".flags.transformers = true; - "semigroups".flags.deepseq = true; - "semigroups".flags.bytestring-builder = false; - "semigroups".flags.template-haskell = true; - "directory".revision = (((hackage."directory")."1.3.3.0").revisions).default; - "transformers-compat".revision = (((hackage."transformers-compat")."0.6.5").revisions).default; - "transformers-compat".flags.five = false; - "transformers-compat".flags.generic-deriving = true; - "transformers-compat".flags.two = false; - "transformers-compat".flags.five-three = true; - "transformers-compat".flags.mtl = true; - "transformers-compat".flags.four = false; - "transformers-compat".flags.three = false; - "template-haskell".revision = (((hackage."template-haskell")."2.14.0.0").revisions).default; - "vector".revision = (((hackage."vector")."0.12.0.3").revisions).default; - "vector".flags.unsafechecks = false; - "vector".flags.internalchecks = false; - "vector".flags.wall = false; - "vector".flags.boundschecks = true; - "primitive".revision = (((hackage."primitive")."0.7.0.0").revisions).default; - "safe".revision = (((hackage."safe")."0.3.17").revisions).default; - "base-compat".revision = (((hackage."base-compat")."0.11.0").revisions).default; - "time-compat".revision = (((hackage."time-compat")."1.9.2.2").revisions).default; - "time-compat".flags.old-locale = false; - "ansi-terminal".revision = (((hackage."ansi-terminal")."0.10.1").revisions).default; - "ansi-terminal".flags.example = false; - "tagged".revision = (((hackage."tagged")."0.8.6").revisions).default; - "tagged".flags.transformers = true; - "tagged".flags.deepseq = true; - "containers".revision = (((hackage."containers")."0.6.0.1").revisions).default; - "integer-logarithms".revision = (((hackage."integer-logarithms")."1.0.3").revisions).default; - "integer-logarithms".flags.check-bounds = false; - "integer-logarithms".flags.integer-gmp = true; - "bytestring".revision = (((hackage."bytestring")."0.10.8.2").revisions).default; - "ansi-wl-pprint".revision = (((hackage."ansi-wl-pprint")."0.6.9").revisions).default; - "ansi-wl-pprint".flags.example = false; - "text".revision = (((hackage."text")."1.2.3.1").revisions).default; - "unordered-containers".revision = (((hackage."unordered-containers")."0.2.10.0").revisions).default; - "unordered-containers".flags.debug = false; - "base".revision = (((hackage."base")."4.12.0.0").revisions).default; - "time".revision = (((hackage."time")."1.8.0.2").revisions).default; - "transformers".revision = (((hackage."transformers")."0.5.6.2").revisions).default; - "hashable".revision = (((hackage."hashable")."1.3.0.0").revisions).default; - "hashable".flags.sse2 = true; - "hashable".flags.integer-gmp = true; - "hashable".flags.sse41 = false; - "hashable".flags.examples = false; - "attoparsec".revision = (((hackage."attoparsec")."0.13.2.3").revisions).default; - "attoparsec".flags.developer = false; - "colour".revision = (((hackage."colour")."2.3.5").revisions).default; - "filepath".revision = (((hackage."filepath")."1.4.2.1").revisions).default; - "process".revision = (((hackage."process")."1.6.5.0").revisions).default; - "pretty".revision = (((hackage."pretty")."1.1.3.6").revisions).default; - "aeson".revision = (((hackage."aeson")."1.4.5.0").revisions).default; - "aeson".flags.cffi = false; - "aeson".flags.fast = false; - "aeson".flags.bytestring-builder = false; - "aeson".flags.developer = false; - "ghc-boot-th".revision = (((hackage."ghc-boot-th")."8.6.5").revisions).default; - "base-orphans".revision = (((hackage."base-orphans")."0.8.1").revisions).default; - "th-abstraction".revision = (((hackage."th-abstraction")."0.3.1.0").revisions).default; - "array".revision = (((hackage."array")."0.5.3.0").revisions).default; - "integer-gmp".revision = (((hackage."integer-gmp")."1.0.2.0").revisions).default; - }; - compiler = { - version = "8.6.5"; - nix-name = "ghc865"; - packages = { - "binary" = "0.8.6.0"; - "ghc-prim" = "0.5.3"; - "unix" = "2.7.2.2"; - "rts" = "1.0"; - "deepseq" = "1.4.4.0"; - "directory" = "1.3.3.0"; - "template-haskell" = "2.14.0.0"; - "containers" = "0.6.0.1"; - "bytestring" = "0.10.8.2"; - "text" = "1.2.3.1"; - "base" = "4.12.0.0"; - "time" = "1.8.0.2"; - "transformers" = "0.5.6.2"; - "filepath" = "1.4.2.1"; - "process" = "1.6.5.0"; - "pretty" = "1.1.3.6"; - "ghc-boot-th" = "8.6.5"; - "array" = "0.5.3.0"; - "integer-gmp" = "1.0.2.0"; - }; - }; - }; - extras = hackage: - { packages = { cabal-sublib = ./.plan.nix/cabal-sublib.nix; }; }; - modules = [ - ({ lib, ... }: - { packages = { "cabal-sublib" = { flags = {}; }; }; }) - ]; - } \ No newline at end of file diff --git a/test/call-cabal-project-to-nix/default.nix b/test/call-cabal-project-to-nix/default.nix index beda8ca7..5d3dadbd 100644 --- a/test/call-cabal-project-to-nix/default.nix +++ b/test/call-cabal-project-to-nix/default.nix @@ -1,26 +1,31 @@ -{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject }: +{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject, recurseIntoAttrs }: with stdenv.lib; let + # This test could use cabalProject', but it does so that it + # tests using callCabalProjectToNix and importAndFilterProject + plan = (importAndFilterProject (callCabalProjectToNix { + name = "test-call-cabal-project-to-nix"; + index-state = "2019-04-30T00:00:00Z"; + # reuse the cabal-simple test project + src = ../cabal-simple; + })); pkgSet = mkCabalProjectPkgSet { - plan-pkgs = (importAndFilterProject (callCabalProjectToNix { - name = "test-call-cabal-project-to-nix"; - index-state = "2019-04-30T00:00:00Z"; - # reuse the cabal-simple test project - src = ../cabal-simple; - })).pkgs; + plan-pkgs = plan.pkgs; }; packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + +in recurseIntoAttrs { + plan-nix = plan.nix; + run = stdenv.mkDerivation { name = "call-cabal-project-to-nix-test"; buildCommand = '' - exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple" + exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}" printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.cabal-simple.components.exes.cabal-simple.run} touch $out ''; @@ -31,4 +36,5 @@ in # Attributes used for debugging with nix repl inherit pkgSet packages; }; - } + }; +} \ No newline at end of file diff --git a/test/call-stack-to-nix/default.nix b/test/call-stack-to-nix/default.nix index f3c0d2b8..2bacfea7 100644 --- a/test/call-stack-to-nix/default.nix +++ b/test/call-stack-to-nix/default.nix @@ -1,25 +1,28 @@ -{ stdenv, mkStackPkgSet, callStackToNix, importAndFilterProject }: +{ stdenv, mkStackPkgSet, callStackToNix, importAndFilterProject, recurseIntoAttrs }: with stdenv.lib; let + stack = importAndFilterProject (callStackToNix { + src = ../stack-simple; + }); pkgSet = mkStackPkgSet { - stack-pkgs = (importAndFilterProject (callStackToNix { - src = ../stack-simple; - })).pkgs; + stack-pkgs = stack.pkgs; pkg-def-extras = []; modules = []; }; packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + +in recurseIntoAttrs { + stack-nix = stack.nix; + run = stdenv.mkDerivation { name = "callStackToNix-test"; buildCommand = '' - exe="${packages.stack-simple.components.exes.stack-simple-exe}/bin/stack-simple-exe" + exe="${packages.stack-simple.components.exes.stack-simple-exe}/bin/stack-simple-exe${stdenv.hostPlatform.extensions.executable}" printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.stack-simple.components.exes.stack-simple-exe.run} touch $out ''; @@ -30,4 +33,5 @@ in # Attributes used for debugging with nix repl inherit pkgSet packages; }; - } + }; +} \ No newline at end of file diff --git a/test/default.nix b/test/default.nix index b573f10b..cbed5224 100644 --- a/test/default.nix +++ b/test/default.nix @@ -6,7 +6,7 @@ with pkgs; let - util = callPackage ./util.nix {}; + util = import ./util.nix { inherit (pkgs.haskell-nix) cabal-install; }; in pkgs.recurseIntoAttrs { inherit (haskell-nix) haskellNixRoots; cabal-simple = haskell-nix.callPackage ./cabal-simple { inherit util; }; diff --git a/test/exe-only/default.nix b/test/exe-only/default.nix index 57620209..baaf91df 100644 --- a/test/exe-only/default.nix +++ b/test/exe-only/default.nix @@ -1,5 +1,5 @@ # Test a package set -{ stdenv, util, haskell-nix }: +{ stdenv, util, haskell-nix, recurseIntoAttrs }: with stdenv.lib; @@ -11,8 +11,9 @@ let packages = project.hsPkgs; -in - stdenv.mkDerivation { +in recurseIntoAttrs { + inherit (project) plan-nix; + run = stdenv.mkDerivation { name = "exe-only-test"; buildCommand = '' @@ -53,4 +54,5 @@ in # This just adds cabal-install to the existing shells. test-shell = util.addCabalInstall packages.exe-only.components.all; }; + }; } diff --git a/test/fully-static/default.nix b/test/fully-static/default.nix index abe4beaf..44ae6136 100644 --- a/test/fully-static/default.nix +++ b/test/fully-static/default.nix @@ -1,22 +1,19 @@ -{ mkStackPkgSet, callStackToNix, importAndFilterProject +{ stackProject' , stdenv, gmp6, openssl, zlib, libffi , buildPackages +, recurseIntoAttrs }: with stdenv.lib; let - # IFD stack-to-nix - stack-pkgs = (importAndFilterProject (callStackToNix { - src = ./.; - })).pkgs; - # Grab the compiler name from stack-to-nix output. # compiler = (stack-pkgs.extras {}).compiler.nix-name; compiler = "ghc865"; # fixme - pkgSet = { gpl ? true }: mkStackPkgSet { - inherit stack-pkgs; + # IFD stack-to-nix + project = { gpl ? true }: stackProject' { + src = ./.; pkg-def-extras = []; modules = [ # Musl libc fully static build @@ -52,10 +49,13 @@ let }) ]; }; - packagesGmp = (pkgSet { gpl = true; }).config.hsPkgs; - packagesIntegerSimple = (pkgSet { gpl = false; }).config.hsPkgs; -in - stdenv.mkDerivation { + packagesGmp = (project { gpl = true; }).hsPkgs; + packagesIntegerSimple = (project { gpl = false; }).hsPkgs; + +in recurseIntoAttrs { + stack-nix-gmp = (project { gpl = true; }).stack-nix; + stack-nix-simple = (project { gpl = false; }).stack-nix; + run = stdenv.mkDerivation { name = "fully-static-test"; depsBuildBuild = [ buildPackages.file ]; @@ -63,10 +63,10 @@ in buildCommand = flip concatMapStrings [ packagesGmp /* packagesIntegerSimple */ ] (packages: '' - exe="${packages.pandoc.components.exes.pandoc}/bin/pandoc" + exe="${packages.pandoc.components.exes.pandoc}/bin/pandoc${stdenv.hostPlatform.extensions.executable}" printf "checking whether executable runs... " >& 2 - $exe --version + ${toString packages.pandoc.components.exes.pandoc.config.testWrapper} $exe --version '' + optionalString stdenv.hostPlatform.isMusl '' printf "checking whether executable is static... " >& 2 @@ -79,8 +79,11 @@ in passthru = { # Attributes used for debugging with nix repl - inherit pkgSet buildPackages stack-pkgs; + inherit buildPackages; + project-gmp = project { gpl = true; }; + project-integer-simple = project { gpl = false; }; pandoc-gmp = packagesGmp.pandoc.components.exes.pandoc; pandoc-integer-simple = packagesIntegerSimple.pandoc.components.exes.pandoc; }; - } + }; +} \ No newline at end of file diff --git a/test/fully-static/stack.yaml b/test/fully-static/stack.yaml index 824bf5df..0112e4f5 100644 --- a/test/fully-static/stack.yaml +++ b/test/fully-static/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-13.26 +resolver: lts-14.13 extra-deps: - pandoc-2.7.3 diff --git a/test/ghc-options/cabal.nix b/test/ghc-options/cabal.nix index dd595d48..6569ab23 100644 --- a/test/ghc-options/cabal.nix +++ b/test/ghc-options/cabal.nix @@ -1,28 +1,25 @@ -{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject }: +{ stdenv, cabalProject', recurseIntoAttrs }: with stdenv.lib; let - plan = (importAndFilterProject (callCabalProjectToNix { - name = "test-ghc-options"; - index-state = "2019-04-30T00:00:00Z"; - src = ./.; - })); - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = plan.pkgs; + project = cabalProject' { + name = "test-ghc-options"; + index-state = "2019-04-30T00:00:00Z"; + src = ./.; # TODO find a way to get the ghc-options into plan.json so we can use it in plan-to-nix modules = [ { packages.test-ghc-options.package.ghcOptions = "-DTEST_GHC_OPTION"; } ]; }; - packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + packages = project.hsPkgs; + +in recurseIntoAttrs { + inherit (project) plan-nix; + run = stdenv.mkDerivation { name = "call-cabal-project-to-nix-test"; buildCommand = '' - exe="${packages.test-ghc-options.components.exes.test-ghc-options-exe}/bin/test-ghc-options-exe" - printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.test-ghc-options.components.exes.test-ghc-options-exe.run} touch $out ''; @@ -31,7 +28,7 @@ in passthru = { # Attributes used for debugging with nix repl - inherit pkgSet packages; - plan-nix = plan.nix; + inherit project packages; }; - } + }; +} \ No newline at end of file diff --git a/test/ghc-options/stack.nix b/test/ghc-options/stack.nix index 36a0711b..9b3bdc16 100644 --- a/test/ghc-options/stack.nix +++ b/test/ghc-options/stack.nix @@ -1,24 +1,21 @@ -{ stdenv, mkStackPkgSet, callStackToNix, importAndFilterProject }: +{ stdenv, stackProject', recurseIntoAttrs }: with stdenv.lib; let - stack = (importAndFilterProject (callStackToNix { + project = stackProject' { src = ./.; - })); - pkgSet = mkStackPkgSet { - stack-pkgs = stack.pkgs; }; - packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + packages = project.hsPkgs; + +in recurseIntoAttrs { + inherit (project) stack-nix; + run = stdenv.mkDerivation { name = "callStackToNix-test"; buildCommand = '' - exe="${packages.test-ghc-options.components.exes.test-ghc-options-exe}/bin/test-ghc-options-exe" - printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.test-ghc-options.components.exes.test-ghc-options-exe.run} touch $out ''; @@ -27,7 +24,7 @@ in passthru = { # Attributes used for debugging with nix repl - inherit pkgSet packages; - stack-nix = stack.nix; + inherit project packages; }; - } + }; +} \ No newline at end of file diff --git a/test/ghc-options/stack.yaml b/test/ghc-options/stack.yaml index aa367ae1..bdcb6953 100644 --- a/test/ghc-options/stack.yaml +++ b/test/ghc-options/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-13.19 +resolver: lts-14.13 packages: - . diff --git a/test/project-flags/cabal.nix b/test/project-flags/cabal.nix index 7492e341..76c7fc1c 100644 --- a/test/project-flags/cabal.nix +++ b/test/project-flags/cabal.nix @@ -1,26 +1,25 @@ -{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject }: +{ stdenv, cabalProject', recurseIntoAttrs }: with stdenv.lib; let - plan = (importAndFilterProject (callCabalProjectToNix { - name = "test-project-flags"; - index-state = "2019-04-30T00:00:00Z"; - src = ./.; - })); - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = plan.pkgs; + project = cabalProject' { + name = "test-project-flags"; + index-state = "2019-04-30T00:00:00Z"; + src = ./.; }; - packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + packages = project.hsPkgs; + +in recurseIntoAttrs { + inherit (project) plan-nix; + run = stdenv.mkDerivation { name = "call-cabal-project-to-nix-test"; buildCommand = '' - exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe" + exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe${stdenv.hostPlatform.extensions.executable}" printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.test-project-flags.components.exes.test-project-flags-exe.run} touch $out ''; @@ -32,4 +31,5 @@ in inherit pkgSet packages; plan-nix = plan.nix; }; - } + }; +} diff --git a/test/project-flags/stack.nix b/test/project-flags/stack.nix index de1b043d..de16d6e1 100644 --- a/test/project-flags/stack.nix +++ b/test/project-flags/stack.nix @@ -1,24 +1,23 @@ -{ stdenv, mkStackPkgSet, callStackToNix, importAndFilterProject }: +{ stdenv, stackProject', recurseIntoAttrs }: with stdenv.lib; let - stack = (importAndFilterProject (callStackToNix { + project = stackProject' { src = ./.; - })); - pkgSet = mkStackPkgSet { - stack-pkgs = stack.pkgs; }; - packages = pkgSet.config.hsPkgs; -in - stdenv.mkDerivation { + packages = project.hsPkgs; + +in recurseIntoAttrs { + inherit (project) stack-nix; + run = stdenv.mkDerivation { name = "callStackToNix-test"; buildCommand = '' - exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe" + exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe${stdenv.hostPlatform.extensions.executable}" printf "checking whether executable runs... " >& 2 - $exe + cat ${packages.test-project-flags.components.exes.test-project-flags-exe.run} touch $out ''; @@ -30,4 +29,5 @@ in inherit pkgSet packages; stack-nix = stack.nix; }; - } + }; +} diff --git a/test/project-flags/stack.yaml b/test/project-flags/stack.yaml index 34242d3d..3d2ab0a4 100644 --- a/test/project-flags/stack.yaml +++ b/test/project-flags/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-13.19 +resolver: lts-14.13 packages: - . diff --git a/test/setup-deps/default.nix b/test/setup-deps/default.nix index 450d3340..995c98f2 100644 --- a/test/setup-deps/default.nix +++ b/test/setup-deps/default.nix @@ -6,7 +6,7 @@ with stdenv.lib; let project = haskell-nix.cabalProject' { name = "test-setup-deps"; - src = ./.; + src = pkgs.haskell-nix.haskellLib.cleanGit { src = ../..; subDir = "test/setup-deps"; }; modules = [{ # Package has no exposed modules which causes # haddock: No input file(s) @@ -16,10 +16,20 @@ let }; packages = project.hsPkgs; -in recurseIntoAttrs { - plan = haskell-nix.withInputs project.plan-nix; +in recurseIntoAttrs (if stdenv.hostPlatform.isWindows + then + let skip = pkgs.runCommand "skip-test-setup-deps" {} '' + echo "Skipping setup-deps test on windows as it needs the ghc lib" >& 2 + touch $out + ''; + in { + plan-nix = skip; + run = skip; + } + else { + inherit (project) plan-nix; run = pkgs.stdenv.mkDerivation { - name = "call-cabal-project-to-nix-test"; + name = "setup-deps-test"; buildCommand = '' exe="${packages.pkg.components.exes.pkg}/bin/pkg" @@ -30,11 +40,12 @@ in recurseIntoAttrs { touch $out ''; - meta.platforms = platforms.all; + meta.platforms = platforms.unix; + meta.disabled = stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWindows; passthru = { # Attributes used for debugging with nix repl inherit project packages; }; }; -} +}) diff --git a/test/shell-for-setup-deps/default.nix b/test/shell-for-setup-deps/default.nix index f2c0cdaa..d6cb710e 100644 --- a/test/shell-for-setup-deps/default.nix +++ b/test/shell-for-setup-deps/default.nix @@ -1,14 +1,11 @@ -{ stdenv, cabal-install, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject }: +{ stdenv, cabal-install, cabalProject', recurseIntoAttrs, runCommand }: with stdenv.lib; let - plan = importAndFilterProject (callCabalProjectToNix { + project = cabalProject' { name = "test-shell-for-setup-deps"; src = ./.; - }); - pkgSet = mkCabalProjectPkgSet { - plan-pkgs = plan.pkgs; modules = [{ # Package has no exposed modules which causes # haddock: No input file(s) @@ -16,10 +13,23 @@ let }]; }; - env = pkgSet.config.hsPkgs.shellFor {}; + env = project.hsPkgs.shellFor {}; - in - stdenv.mkDerivation { +in recurseIntoAttrs (if stdenv.hostPlatform.isWindows + then + let skip = runCommand "skipping-test-shell-for-setup-deps" {} '' + echo "Skipping shell-for-setup-deps test on windows as does not work yet" >& 2 + touch $out + ''; + in { + plan-nix = skip; + env = skip; + run = skip; + } + else { + inherit (project) plan-nix; + inherit env; + run = stdenv.mkDerivation { name = "shell-for-test"; buildCommand = '' @@ -35,14 +45,14 @@ let ''; meta.platforms = platforms.all; - meta.disabled = stdenv.hostPlatform.isMusl; + meta.disabled = stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWindows; passthru = { # Used for debugging with nix repl inherit pkgSet; # Used for testing externally with nix-shell (../tests.sh). - inherit env; - plan-nix = plan.nix; + inherit project env; }; -} + }; +}) diff --git a/test/shell-for/default.nix b/test/shell-for/default.nix index ba9e6b12..5c959f1d 100644 --- a/test/shell-for/default.nix +++ b/test/shell-for/default.nix @@ -1,4 +1,4 @@ -{ stdenv, cabal-install, mkCabalProjectPkgSet }: +{ stdenv, cabal-install, mkCabalProjectPkgSet, recurseIntoAttrs, runCommand }: with stdenv.lib; @@ -44,8 +44,21 @@ let buildInputs = [ cabal-install ]; }; - in - stdenv.mkDerivation { +in recurseIntoAttrs (if stdenv.hostPlatform.isWindows + then + let skip = runCommand "skip-test-shell-for" {} '' + echo "Skipping shell-for test on windows as does not work yet" >& 2 + touch $out + ''; + in { + env = skip; + envPkga = skip; + envDefault = skip; + run = skip; + } + else { + inherit env envPkga envDefault; + run = stdenv.mkDerivation { name = "shell-for-test"; buildCommand = '' @@ -64,7 +77,7 @@ let ''; meta.platforms = platforms.all; - meta.disabled = stdenv.hostPlatform.isMusl; + meta.disabled = stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWindows; passthru = { # Used for debugging with nix repl @@ -73,4 +86,5 @@ let # Used for testing externally with nix-shell (../tests.sh). inherit env envPkga envDefault; }; -} + }; +}) diff --git a/test/snapshots/default.nix b/test/snapshots/default.nix index b218b78b..85540dc0 100644 --- a/test/snapshots/default.nix +++ b/test/snapshots/default.nix @@ -1,16 +1,32 @@ -{ stdenv, haskellPackages, snapshots }: +{ stdenv, haskellPackages, snapshots, recurseIntoAttrs, runCommand }: with stdenv.lib; let - env = snapshots."lts-12.21".ghcWithHoogle + env = snapshots."lts-14.13".ghcWithHoogle (ps: with ps; [ conduit conduit-extra resourcet ]); -in - stdenv.mkDerivation { +in recurseIntoAttrs (if stdenv.hostPlatform.isWindows + then + let skip = runCommand "skip-test-snapshot" {} '' + echo "Skipping snapshot test on windows as does not work yet" >& 2 + touch $out + ''; + in { + env = skip; + run = skip; + } + else { + inherit env; + run = stdenv.mkDerivation { name = "shell-for-test"; - buildCommand = '' + buildCommand = if stdenv.hostPlatform.isWindows + then '' + printf "snapshot test is not working yet for windows. skipping. " >& 2 + touch $out + '' + else '' ######################################################################## # test single component from haskellPackages @@ -33,4 +49,5 @@ in passthru = { inherit env; }; -} + }; +}) diff --git a/test/with-packages/default.nix b/test/with-packages/default.nix index 64e49e56..f4a7f303 100644 --- a/test/with-packages/default.nix +++ b/test/with-packages/default.nix @@ -1,4 +1,4 @@ -{ stdenv, util, mkPkgSet }: +{ stdenv, util, mkPkgSet, recurseIntoAttrs }: with stdenv.lib; with util; @@ -35,8 +35,15 @@ let pkgId = p: "${p.identifier.name}-${p.identifier.version}"; showDepends = component: concatMapStringsSep " " pkgId component.depends; -in - stdenv.mkDerivation { +in recurseIntoAttrs { + # Used for testing externally with nix-shell (../tests.sh). + # This just adds cabal-install to the existing shells. + test-shell = addCabalInstall packages.test-with-packages.components.all; + + # A variant of test-shell with the component option doExactConfig enabled + test-shell-dec = addCabalInstall packages.test-with-packages.components.library; + + run = stdenv.mkDerivation { name = "with-packages-test"; libraryDepends = showDepends pkgSet.config.packages.test-with-packages.components.library; allDepends = showDepends pkgSet.config.packages.test-with-packages.components.all; @@ -60,15 +67,19 @@ in printf "checking that the 'library' component works... " >& 2 echo ${package.components.library} >& 2 + '' + (if stdenv.hostPlatform.isWindows + then '' + printf "runghc tests are not working yet for windows. skipping. " >& 2 + '' + else '' + printf "checking that the package env has the dependencies... " >& 2 + ${package.components.all.env}/bin/runghc ${./Point.hs} + echo >& 2 - printf "checking that the package env has the dependencies... " >& 2 - ${package.components.all.env}/bin/runghc ${./Point.hs} - echo >& 2 - - printf "checking that components.library.env has the dependencies... " >& 2 - ${library.env}/bin/runghc ${./Point.hs} - echo >& 2 - + printf "checking that components.library.env has the dependencies... " >& 2 + ${library.env}/bin/runghc ${./Point.hs} + echo >& 2 + '') + '' touch $out ''; @@ -78,12 +89,6 @@ in passthru = { # Used for debugging with nix repl inherit packages pkgSet; - - # Used for testing externally with nix-shell (../tests.sh). - # This just adds cabal-install to the existing shells. - test-shell = addCabalInstall packages.test-with-packages.components.all; - - # A variant of test-shell with the component option doExactConfig enabled - test-shell-dec = addCabalInstall packages.test-with-packages.components.library; }; + }; }