diff --git a/WORKSPACE b/WORKSPACE index cbe0c3e64..3065cd3bd 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -33,6 +33,32 @@ load("@os_info//:os_info.bzl", "is_linux", "is_windows") # bazel dependencies haskell_repositories() +load("@io_tweag_rules_haskell//haskell:cabal.bzl", "stack_install") + +stack_install( + name = "stackage", + packages = [ + # Core libraries + "array", + "base", + "directory", + "filepath", + "process", + # For tests + "streaming", + "void", + "hspec", + "hspec-core", + "lens-family-core", + "data-default-class", + "lens-labels", + "proto-lens", + "lens-family", + ], + snapshot = "lts-13.15", + deps = ["@zlib.dev//:zlib"], +) + rules_nixpkgs_version = "0.5.2" rules_nixpkgs_version_is_hash = False @@ -52,29 +78,10 @@ load( "nixpkgs_local_repository", "nixpkgs_package", ) -load( - "@io_tweag_rules_haskell//haskell:nixpkgs.bzl", - "haskell_nixpkgs_package", - "haskell_nixpkgs_packageset", -) -load( - "@io_tweag_rules_haskell//tests/external-haskell-repository:workspace_dummy.bzl", - "haskell_package_repository_dummy", -) -load( - "@io_tweag_rules_haskell//:constants.bzl", - "test_ghc_version", -) -haskell_nixpkgs_package( +nixpkgs_package( name = "ghc", - attribute_path = "haskellPackages.ghc", - nix_file = "//tests:ghc.nix", - nix_file_deps = ["//nixpkgs:default.nix"], - # rules_nixpkgs assumes we want to read from `` implicitly - # if `repository` is not set, but our nix_file uses `./nixpkgs/`. - # TODO(Profpatsch) - repositories = {"nixpkgs": "//nixpkgs:NOTUSED"}, + repository = "@nixpkgs", ) http_archive( @@ -109,18 +116,22 @@ test_repl_ghci_args = [ "-XOverloadedStrings", ] +load( + "@io_tweag_rules_haskell//:constants.bzl", + "test_ghc_version", +) load( "@io_tweag_rules_haskell//haskell:nixpkgs.bzl", "haskell_register_ghc_nixpkgs", ) haskell_register_ghc_nixpkgs( + attribute_path = "ghc", compiler_flags = test_compiler_flags, haddock_flags = test_haddock_flags, locale_archive = "@glibc_locales//:locale-archive", - nix_file = "//tests:ghc.nix", - nix_file_deps = ["//nixpkgs:default.nix"], repl_ghci_args = test_repl_ghci_args, + repositories = {"nixpkgs": "@nixpkgs"}, version = test_ghc_version, ) @@ -159,12 +170,29 @@ cc_library( name = "zlib", linkstatic = 1, srcs = [":lib"], - testonly = 1, ) """, repository = "@nixpkgs", ) +nixpkgs_package( + name = "c2hs", + attribute_path = "haskellPackages.c2hs", + repository = "@nixpkgs", +) + +nixpkgs_package( + name = "doctest", + attribute_path = "haskellPackages.doctest", + repository = "@nixpkgs", +) + +nixpkgs_package( + name = "proto-lens-protoc", + attribute_path = "haskellPackages.proto-lens-protoc", + repository = "@nixpkgs", +) + nixpkgs_package( name = "sphinx", attribute_path = "python36Packages.sphinx", @@ -191,14 +219,12 @@ package(default_visibility = ["//visibility:public"]) filegroup ( name = "include", srcs = glob(["include/*.h"]), - testonly = 1, ) cc_library( name = "zlib", deps = ["@zlib//:zlib"], hdrs = [":include"], - testonly = 1, strip_include_prefix = "include", ) """, @@ -219,22 +245,6 @@ filegroup( repository = "@nixpkgs", ) -haskell_nixpkgs_packageset( - name = "hackage-packages", - base_attribute_path = "haskellPackages", - nix_file = "//tests:ghc.nix", - nix_file_deps = ["//tests/haddock:libC.nix"], - nixopts = [ - "-j", - "1", - ], - repositories = {"nixpkgs": "@nixpkgs"}, -) - -load("@hackage-packages//:packages.bzl", "import_packages") - -import_packages(name = "hackage") - load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") jvm_maven_import_external( @@ -251,6 +261,11 @@ local_repository( path = "tests/c2hs/repo", ) +load( + "@io_tweag_rules_haskell//tests/external-haskell-repository:workspace_dummy.bzl", + "haskell_package_repository_dummy", +) + # dummy repo for the external haskell repo test (hazel) haskell_package_repository_dummy( name = "haskell_package_repository_dummy", @@ -363,13 +378,3 @@ buildifier_dependencies() load("@ai_formation_hazel//:workspace.bzl", "hazel_setup") hazel_setup() - -load("@io_tweag_rules_haskell//haskell:cabal.bzl", "stack_install") - -stack_install( - name = "stackage", - testonly = 1, - packages = ["stack"], - snapshot = "lts-13.15", - deps = ["@zlib.dev//:zlib"], -) diff --git a/constants.bzl b/constants.bzl index 930fc8e38..655358fad 100644 --- a/constants.bzl +++ b/constants.bzl @@ -1 +1 @@ -test_ghc_version = "8.6.4" +test_ghc_version = "8.6.5" diff --git a/haskell/nixpkgs.bzl b/haskell/nixpkgs.bzl index 381edc2e2..bb505de39 100644 --- a/haskell/nixpkgs.bzl +++ b/haskell/nixpkgs.bzl @@ -394,7 +394,7 @@ def haskell_register_ghc_nixpkgs( toolchain_repo_name = "io_tweag_rules_haskell_ghc_nixpkgs_toolchain" # The package from the system. - haskell_nixpkgs_package( + nixpkgs_package( name = nixpkgs_ghc_repo_name, attribute_path = attribute_path, build_file = build_file, diff --git a/shell.nix b/shell.nix index 64287ca76..a2481c26b 100644 --- a/shell.nix +++ b/shell.nix @@ -16,6 +16,9 @@ mkShell { perl python3 bazel + # For stack_install. TODO Remove ghc when move to Stack 2. + stack + ghc # Needed for @com_github_golang_protobuf, itself needed by buildifier. git # Needed to get correct locale for tests with encoding diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 276db5546..cc9799817 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -22,7 +22,7 @@ package(default_testonly = 1) haskell_doctest_toolchain( name = "doctest-toolchain", - doctest = "@hackage-doctest//:bin", + doctest = "@doctest//:bin", tags = ["requires_doctest"], ) @@ -34,7 +34,7 @@ haskell_doctest_toolchain( haskell_proto_toolchain( name = "protobuf-toolchain", testonly = 0, - plugin = "@hackage-proto-lens-protoc//:bin/proto-lens-protoc", + plugin = "@proto-lens-protoc//:bin/proto-lens-protoc", protoc = "@com_google_protobuf//:protoc", tags = ["requires_hackage"], deps = [ @@ -44,17 +44,17 @@ haskell_proto_toolchain( "//tests/hackage:deepseq", "//tests/hackage:mtl", "//tests/hackage:text", - "@hackage//:data-default-class", - "@hackage//:lens-family", - "@hackage//:lens-family-core", - "@hackage//:lens-labels", - "@hackage//:proto-lens", + "@stackage//:data-default-class", + "@stackage//:lens-family", + "@stackage//:lens-family-core", + "@stackage//:lens-labels", + "@stackage//:proto-lens", ], ) c2hs_toolchain( name = "c2hs-toolchain", - c2hs = "@hackage-c2hs//:bin", + c2hs = "@c2hs//:bin", tags = ["requires_c2hs"], ) @@ -316,7 +316,7 @@ haskell_binary( deps = [ "//tests/hackage:base", "//tests/hackage:process", - "@hackage//:hspec", - "@hackage//:hspec-core", + "@stackage//:hspec", + "@stackage//:hspec-core", ], ) diff --git a/tests/binary-with-prebuilt/BUILD.bazel b/tests/binary-with-prebuilt/BUILD.bazel index 99a22ae99..7b3a9e955 100644 --- a/tests/binary-with-prebuilt/BUILD.bazel +++ b/tests/binary-with-prebuilt/BUILD.bazel @@ -13,7 +13,7 @@ haskell_test( deps = [ "//tests/hackage:base", "//tests/hackage:template-haskell", - "@hackage//:streaming", - "@hackage//:void", + "@stackage//:streaming", + "@stackage//:void", ], ) diff --git a/tests/ghc.nix b/tests/ghc.nix deleted file mode 100644 index cde169991..000000000 --- a/tests/ghc.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ pkgs ? import ../nixpkgs {} -# Whether we want to wrap the packages using . -# When this is called from inside bazel, we need to wrap the haskell package -# set using . Otherwise we don't need (and don't want) -# to. -, wrapPackages ? (builtins.tryEval ).success -}: - -with pkgs; - -let haskellPackages = pkgs.haskell.packages.ghc864.override { - overrides = with pkgs.haskell.lib; self: super: rec { - libc = import ./haddock/libC.nix self pkgs; - }; - }; - genBazelBuild = - if wrapPackages - then callPackage {} - else (x: x); - -in - { - ghc = haskellPackages.ghcWithPackages (p: with p; [ - - # haskell_proto_library inputs - bytestring - containers - data-default-class - lens-family - lens-labels - proto-lens - text - - # test inputs - libc - - # for test runner - hspec - ]); - haskellPackages = genBazelBuild haskellPackages; -} diff --git a/tests/haddock/BUILD.bazel b/tests/haddock/BUILD.bazel index d6035132a..bd637c354 100644 --- a/tests/haddock/BUILD.bazel +++ b/tests/haddock/BUILD.bazel @@ -48,7 +48,6 @@ haskell_library( ":haddock-lib-a", "//tests/hackage:base", "//tests/hackage:template-haskell", - "@hackage//:libc", "@zlib", ], ) diff --git a/tests/haddock/LibB.hs b/tests/haddock/LibB.hs index b4df1ffcb..3648ed2bb 100644 --- a/tests/haddock/LibB.hs +++ b/tests/haddock/LibB.hs @@ -5,17 +5,12 @@ module LibB where import LibA.A (a) import LibA (f) -import LibC (mytype, LibCType) import TH (foo) -- | Doc for 'x' using 'f' and 'a' and 'Int'. x :: Int x = const f a --- | This uses a type from an undocumented package -y :: LibCType -y = mytype - -- | A thing generated with TH. z :: String z = $foo diff --git a/tests/haddock/libC.nix b/tests/haddock/libC.nix deleted file mode 100644 index d34517883..000000000 --- a/tests/haddock/libC.nix +++ /dev/null @@ -1,47 +0,0 @@ -# A trivial `haskellPackages` library that has haddock generation disabled -self: pkgs: -let - # pkgs = import ../../nixpkgs.nix {}; - - libC = pkgs.writeText "LibC.hs" '' - {-# language NoImplicitPrelude #-} - module LibC where - - data LibCType = LibCType - - -- | myfunction - mytype :: LibCType - mytype = LibCType - ''; - - cabal = pkgs.writeText "libc.cabal" '' - name: libc - version: 0.1.0.0 - build-type: Simple - cabal-version: >=1.10 - - library - default-language: Haskell2010 - exposed-modules: LibC - ''; - - src = pkgs.runCommand "libc-src" {} '' - mkdir $out - cp ${libC} $out/LibC.hs - cp ${cabal} $out/libc.cabal - ''; - -in - # This call means the `.haddock` file is not generated, - # even though the ghc package still references the location - # where it would ordinarily be. - pkgs.haskell.lib.dontHaddock - - (self.callPackage - ({ mkDerivation }: mkDerivation { - pname = "libc"; - version = "0.1.0.0"; - src = src; - license = pkgs.lib.licenses.mit; - isExecutable = false; - }) {}) diff --git a/tests/repl-targets/BUILD.bazel b/tests/repl-targets/BUILD.bazel index 2fd78bfd6..f734412f8 100644 --- a/tests/repl-targets/BUILD.bazel +++ b/tests/repl-targets/BUILD.bazel @@ -59,7 +59,7 @@ haskell_library( deps = [ "//tests/data:ourclibrary", "//tests/hackage:base", - "@hackage//:array", + "@stackage//:array", "@zlib", ], ) diff --git a/tools/runfiles/BUILD.bazel b/tools/runfiles/BUILD.bazel index bc99b96c0..b49a80582 100644 --- a/tools/runfiles/BUILD.bazel +++ b/tools/runfiles/BUILD.bazel @@ -10,9 +10,9 @@ haskell_library( src_strip_prefix = "src", visibility = ["//visibility:public"], deps = [ - "@hackage//:base", - "@hackage//:directory", - "@hackage//:filepath", + "@stackage//:base", + "@stackage//:directory", + "@stackage//:filepath", ], ) @@ -24,8 +24,8 @@ haskell_test( src_strip_prefix = "bin", deps = [ ":runfiles", - "@hackage//:base", - "@hackage//:filepath", + "@stackage//:base", + "@stackage//:filepath", ], ) @@ -39,8 +39,8 @@ haskell_test( src_strip_prefix = "test", deps = [ ":runfiles", - "@hackage//:base", - "@hackage//:filepath", - "@hackage//:process", + "@stackage//:base", + "@stackage//:filepath", + "@stackage//:process", ], )