Rules for defining toolchains
Bazel

Rules for defining toolchains


haskell_toolchain

haskell_toolchain(name, version, tools, compiler_flags, repl_ghci_args)

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).

Attributes

name

Name; Required

A unique name for this rule.

version

Unknown; Required

tools

Unknown; Required

compiler_flags

List of strings; Optional

repl_ghci_args

List of strings; Optional

Examples

In a BUILD file:

haskell_toolchain(
    name = "ghc",
    version = '1.2.3'
    tools = ["@sys_ghc//:bin"],
    compiler_flags = ["-Wall"],
    c2hs = "@c2hs//:bin", # optional
)

where @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")

and for @c2hs:

nixpkgs_package(
    name = "c2hs",
    attribute_path = "haskell.packages.ghc822.c2hs",
)