Workspace rules (Nixpkgs)
Bazel

Workspace rules (Nixpkgs)


check_ghc_version

check_ghc_version(repository_ctx)

Attributes

repository_ctx required

ghc_nixpkgs_toolchain_declaration

ghc_nixpkgs_toolchain_declaration(target_constraints, exec_constraints, cpu_value, os_name,
                                  haskell_toolchain_repo_name, toolchain_name)

Attributes

target_constraints required
exec_constraints required
cpu_value required
os_name required
haskell_toolchain_repo_name required
toolchain_name required

haskell_register_ghc_nixpkgs

haskell_register_ghc_nixpkgs(version, name, is_static, static_runtime, fully_static_link,
                             build_file, build_file_content, compiler_flags, ghcopts,
                             compiler_flags_select, haddock_flags, repl_ghci_args, cabalopts,
                             locale_archive, attribute_path, sh_posix_attributes, nix_file,
                             nix_file_deps, nixopts, locale, repositories, repository,
                             nix_file_content, exec_constraints, target_constraints, register)

Register a package from Nixpkgs as a toolchain.

Toolchains can be used to compile Haskell code. To have this toolchain selected during toolchain resolution, set a host platform that includes the @rules_nixpkgs_core//constraints:support_nix constraint value.

Examples

haskell_register_ghc_nixpkgs(
    locale_archive = "@glibc_locales//:locale-archive",
    atttribute_path = "haskellPackages.ghc",
    version = "1.2.3",   # The version of GHC
)

Setting the host platform can be done on the command-line like in the following:

--host_platform=@rules_nixpkgs_core//platforms:host

Attributes

version required
name optional; default is "rules_haskell"
is_static optional; default is None

Deprecated. The functionality it previously gated (supporting GHC versions with static runtime systems) now sits under static_runtime, a name chosen to avoid confusion with the new flag fully_static_link, which controls support for fully-statically-linked binaries. During the deprecation period, we rewrite is_static to static_runtime in this macro as long as the new attributes aren’t also used. This argument and supporting code should be removed in a future release.

static_runtime optional; default is None

True if and only if a static GHC runtime is to be used. This is required in order to use statically-linked Haskell libraries with GHCi and Template Haskell.

build_file optional; default is None

Passed to nixpkgs_package

build_file_content optional; default is None

Passed to nixpkgs_package

compiler_flags optional; default is None

DEPRECADED. Use new name ghcopts.

ghcopts optional; default is None

A collection of flags that will be passed to GHC

compiler_flags_select optional; default is None

temporary workaround to pass conditional arguments. See https://github.com/bazelbuild/bazel/issues/9199 for details.

haddock_flags optional; default is None
repl_ghci_args optional; default is None
cabalopts optional; default is None
locale_archive optional; default is None
attribute_path optional; default is "haskellPackages.ghc"

Passed to nixpkgs_package

sh_posix_attributes optional; default is None

List of attribute paths to extract standard Unix shell tools from. Passed to nixpkgs_sh_posix_configure.

nix_file optional; default is None

Passed to nixpkgs_package

nix_file_deps optional; default is []

Passed to nixpkgs_package

nixopts optional; default is None

Passed to nixpkgs_package

locale optional; default is None
repositories optional; default is {}

Passed to nixpkgs_package

repository optional; default is None

Passed to nixpkgs_package

nix_file_content optional; default is None

Passed to nixpkgs_package

exec_constraints optional; default is []
target_constraints optional; default is []
register optional; default is True

Whether to register the toolchain (must be set to False if bzlmod is enabled)


register_ghc_from_nixpkgs_package

register_ghc_from_nixpkgs_package(version, nixpkgs_ghc, name, is_static, static_runtime,
                                  fully_static_link, ghcopts, compiler_flags_select, haddock_flags,
                                  repl_ghci_args, cabalopts, locale_archive, locale, exec_constraints,
                                  target_constraints, register)

Register a pre-existing package from Nixpkgs as a toolchain.

This rule is similar haskell_register_ghc_nixpkgs, but it does not setup any nix package itself.

Attributes

version required

The version of the provided ghc.

nixpkgs_ghc required

The label of a nix-installed ghc_binary

name required

The name for this toolchain.

is_static optional; default is None

Deprecated. The functionality it previously gated (supporting GHC versions with static runtime systems) now sits under static_runtime, a name chosen to avoid confusion with the new flag fully_static_link, which controls support for fully-statically-linked binaries. During the deprecation period, we rewrite is_static to static_runtime in this macro as long as the new attributes aren’t also used. This argument and supporting code should be removed in a future release.

static_runtime optional; default is None

True if and only if a static GHC runtime is to be used. This is required in order to use statically-linked Haskell libraries with GHCi and Template Haskell.

ghcopts optional; default is None

A collection of flags that will be passed to GHC

compiler_flags_select optional; default is None

temporary workaround to pass conditional arguments. See https://github.com/bazelbuild/bazel/issues/9199 for details.

haddock_flags optional; default is None
repl_ghci_args optional; default is None
cabalopts optional; default is None
locale_archive optional; default is None
locale optional; default is None
exec_constraints optional; default is []
target_constraints optional; default is []
register optional; default is True

Whether to register the toolchain (must be set to False if bzlmod is enabled)