Settings for individual Haskell packages can be specified in the settings attribute of a haskellProjects module.
haskellProjects.default = {
settings = {
ema = { # This module can take `{self, super, ...}` args, optionally.
# Disable running tests
check = false;
# Disable building haddock (documentation)
haddock = false;
# Ignore Cabal version constraints
jailbreak = true;
# Extra non-Haskell dependencies
extraBuildDepends = [ pkgs.stork ];
# Library-specific dependencies
librarySystemDepends = [ pkgs.zlib ];
libraryPkgconfigDepends = [ pkgs.openssl ];
# Source patches
patches = [ ./patches/ema-bug-fix.patch ];
# Enable/disable Cabal flags
cabalFlags.with-generics = true;
# Allow building a package marked as "broken"
broken = false;
};
};
};nixpkgs functions
-
The
pkgs.haskell.libmodule provides various utility functions that you can use to override Haskell packages. The canonical place to find documentation on these is the source. haskell-flake provides asettingssubmodule for convenience. For eg., thedontCheckfunction translates tosettings.<name>.check; the full list of options can be seen here.
Sharing package settings
Project modules export both packages and settings options for reuse in downstream Haskell projects.
Custom settings
You can provide custom settings for use in multiple packages (even across multiple repos). For example, see this Emanote change which demonstrates how to add a new setting option (removeReferencesTo).
Extra settings
haskell-flake provides the following settings on top of those provided by nixpkgs.
drvAttrs
Set arbitrary attributes on the Haskell package derivation. This is a simpler alternative to the custom option for setting derivation attributes like environment variables.
settings = {
foo = {
drvAttrs = {
GIT_BIN = lib.getExe' pkgs.git "git";
SOME_ENV_VAR = "value";
};
};
};
Unlike custom, the drvAttrs option composes well with other settings and doesn’t require writing a function.
generateOptparseApplicativeCompletions
Generate and install shell completion files for executables. The executables need to be using optparse-applicative for this to work. Note that this feature is automatically disabled when cross-compiling, since it requires executing the binaries in question.
removeReferencesTo
Remove references to other packages from this Haskell package. This is useful to eliminate unnecessary data dependencies from your Haskell executable so as to reduce its closure size.
buildFromSdist
Newer versions of nixpkgs provide buildFromSdist to build your package from the cabal sdist tarball. This is enabled by default, to help with checking release-worthiness of your packages.
buildFromSdist
If you encounter issues with buildFromSdist you can disable it by setting settings.<name>.buildFromSdist to true.
stan
Run STatic ANalysis on the package using stan and generate an HTML report. The report is created in the /nix/store path alongside your package outputs.
This setting looks for a .stan.toml file in the root of the package source. See a sample .stan.toml configuration for reference.