Rules for defining toolchains

Rules

get_cc_toolchain

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_cc_toolchain")

get_cc_toolchain(
    # A unique name for this target.
    name = "",
)

name

A unique name for this target.


get_haskell_toolchain

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_haskell_toolchain")

get_haskell_toolchain(
    # A unique name for this target.
    name = "",
)

name

A unique name for this target.


get_nodejs_toolchain

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_nodejs_toolchain")

get_nodejs_toolchain(
    # A unique name for this target.
    name = "",
)

name

A unique name for this target.


get_posix_toolchain

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_posix_toolchain")

get_posix_toolchain(
    # A unique name for this target.
    name = "",
)

name

A unique name for this target.


Macros and Functions

get_cc_toolchain_impl

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_cc_toolchain_impl")

get_cc_toolchain_impl(
    ctx = None,
)

ctx


get_haskell_toolchain_impl

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_haskell_toolchain_impl")

get_haskell_toolchain_impl(
    ctx = None,
)

ctx


get_nodejs_toolchain_impl

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_nodejs_toolchain_impl")

get_nodejs_toolchain_impl(
    ctx = None,
)

ctx


get_posix_toolchain_impl

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "get_posix_toolchain_impl")

get_posix_toolchain_impl(
    ctx = None,
)

ctx


haskell_toolchain

Declare a compiler toolchain.

You need at least one of these declared somewhere in your BUILD files for the other rules to work. Once declared, you then need to register the toolchain using register_toolchains in your WORKSPACE file (see example below).

Examples

In a BUILD file:

haskell_toolchain(
    name = "ghc",
    version = "1.2.3",
    static_runtime = static_runtime,
    fully_static_link = fully_static_link,
    tools = ["@sys_ghc//:bin"],
    ghcopts = ["-Wall"],
)

where @sys_ghc is an external repository defined in the WORKSPACE, e.g. using:

nixpkgs_package(
    name = 'sys_ghc',
    attribute_path = 'haskell.compiler.ghc822',
)

register_toolchains("//:ghc")

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "haskell_toolchain")

haskell_toolchain(
    # A unique name for this toolchain.
    name = "",
    # Version of your GHC compiler
    version = None,
    # Whether GHC was linked with a static runtime.
    static_runtime = None,
    # Whether GHC should build fully-statically-linked binaries.
    fully_static_link = None,
    # GHC and executables that come with it
    tools = None,
    # The set of libraries that come with GHC
    libraries = None,
)

name

A unique name for this toolchain.

version

Version of your GHC compiler. It has to match the version reported by the GHC used by bazel.

static_runtime

Whether GHC was linked with a static runtime.

Whether GHC should build fully-statically-linked binaries.

tools

GHC and executables that come with it. First item takes precedence.

libraries

The set of libraries that come with GHC. Requires haskell_import targets.

asterius_binaries

An optional filegroup containing asterius binaries. If present the toolchain will target WebAssembly and only use binaries from tools if needed to complete the toolchain.

compiler_flags

DEPRECATED. Use new name ghcopts.

ghcopts

A collection of flags that will be passed to GHC on every invocation.

repl_ghci_args

A collection of flags that will be passed to GHCI on repl invocation. It extends the ghcopts collection.
Flags set here have precedance over ghcopts.

haddock_flags

A collection of flags that will be passed to haddock.

cabalopts

Additional flags to pass to Setup.hs configure for all Cabal rules.
Note, Cabal rules do not read the toolchain attributes ghcopts, compiler_flags or haddock_flags.
Use --ghc-option=OPT to configure additional compiler flags.
Use --haddock-option=OPT to configure additional haddock flags.
Use --haddock-option=--optghc=OPT if haddock generation requires additional compiler flags.

locale_archive

Label pointing to the locale archive file to use.
Linux-specific and mostly useful on NixOS.

kwargs

Common rule attributes. See Bazel documentation.


rules_haskell_toolchains

Register GHC binary distributions for all platforms as toolchains.

Toolchains can be used to compile Haskell code. This function registers one toolchain for each known binary distribution on all platforms of the given GHC version. During the build, one toolchain will be selected based on the host and target platforms (See toolchain resolution).

Example usage (generated)

load("@rules_haskell//haskell:toolchain.bzl", "rules_haskell_toolchains")

rules_haskell_toolchains(
)

version

The desired GHC version

compiler_flags

DEPRECATED. Use new name ghcopts.

ghcopts

A collection of flags that will be passed to GHC on every invocation.

haddock_flags

repl_ghci_args

cabalopts

locale

Locale that will be set during compiler invocations. Default: C.UTF-8 (en_US.UTF-8 on MacOS)