Workspace rules (Nixpkgs)
Bazel

Workspace rules (Nixpkgs)


haskell_nixpkgs_package

haskell_nixpkgs_package(name, attribute_path, nix_file_deps, repositories, build_file_content, build_file, **kwargs)

Load a single haskell package. The package is expected to be in the form of the packages generated by genBazelBuild.nix

Attributes

name

Name; Required

A unique name for this rule.

attribute_path

Unknown; Required

nix_file_deps

List of strings; Optional

repositories

Unknown; Optional

build_file_content

Unknown; Optional

build_file

Unknown; Optional

**kwargs

Unknown; Optional


haskell_nixpkgs_packages

haskell_nixpkgs_packages(name, base_attribute_path, packages, **kwargs)

Import a set of haskell packages from nixpkgs.

This takes as input the same arguments as nixpkgs_package, expecting the attribute_path to resolve to a set of haskell packages (such as haskellPackages or haskell.packages.ghc822) preprocessed by the genBazelBuild function. It also takes as input a list of packages to import (which can be generated by the gen_packages_list function).

Attributes

name

Name; Required

A unique name for this rule.

base_attribute_path

Unknown; Required

packages

Unknown; Required

**kwargs

Unknown; Optional


haskell_nixpkgs_packageset

haskell_nixpkgs_packageset(name, base_attribute_path, repositories, **kwargs)

Import all the available haskell packages. The arguments are the same as the arguments of nixpkgs_package, except for the base_attribute_path which should point to an haskellPackages set in the nix expression

Attributes

name

Name; Required

A unique name for this rule.

base_attribute_path

Unknown; Required

repositories

Unknown; Optional

**kwargs

Unknown; Optional

Examples

In haskellPackages.nix:

with import <nixpkgs> {};

let wrapPackages = callPackage <bazel_haskell_wrapper> { }; in
{ haskellPackages = wrapPackages haskell.packages.ghc822; }

In your WORKSPACE

# Define a nix repository to fetch the packages from
load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
    "nixpkgs_git_repository")
nixpkgs_git_repository(
    name = "nixpkgs",
    revision = "9a787af6bc75a19ac9f02077ade58ddc248e674a",
)

load("@io_tweag_rules_haskell//haskell:nixpkgs.bzl",
    "haskell_nixpkgs_packageset",

# Generate a list of all the available haskell packages
haskell_nixpkgs_packageset(
    name = "hackage-packages",
    repositories = {"@nixpkgs": "nixpkgs"},
    nix_file = "//haskellPackages.nix",
    base_attribute_path = "haskellPackages",
)
load("@hackage-packages//:packages.bzl", "import_packages")
import_packages(name = "hackage")

Then in your BUILD files, you can access to the whole of hackage as @hackage//:{your-package-name}


haskell_register_ghc_nixpkgs

haskell_register_ghc_nixpkgs(version, build_file, compiler_flags, compiler_flags_select, haddock_flags, repl_ghci_args, locale_archive, attribute_path, nix_file, nix_file_deps, repositories)

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 @io_tweag_rules_haskell//haskell/platforms:nixpkgs constraint value.

Attributes

version

Unknown; Required

build_file

Unknown; Optional

compiler_flags

Unknown; Optional

compiler_flags_select

Unknown; Optional

haddock_flags

Unknown; Optional

repl_ghci_args

Unknown; Optional

locale_archive

Unknown; Optional

attribute_path

String; Optional

nix_file

Unknown; Optional

nix_file_deps

List of strings; Optional

repositories

Unknown; Optional

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:

[email protected]_tweag_rules_haskell//haskell/platforms:linux_x86_64_nixpkgs