Loading of haskell packages from nixpkgs
Bazel

Loading of haskell packages from 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:nix.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}