This repo contains build code and tools shared between IOHK projects.
- Pinned versions of input-output-hk/nixpkgs.
- Haskell.nix and
nix-tools
, plus package overlays and patches for cross-compiling to Windows. - Scripts for regenerating code with
nix-tools
. - Util functions such as source filtering.
- Nix builds of development tools such as HLint, ShellCheck, Stylish Haskell, SHC, cache-s3.
- Nix packages and overlay for the rust-cardano projects.
Use iohk-nix
by "pinning" its git revision and source hash in a JSON
file. Then use iohk-nix to get nixpkgs. This is usually done with the
default arguments to default.nix
. For example:
# default.nix
{ config ? {}
, system ? builtins.currentSystem
, iohkLib ? import ./nix/iohk-common.nix { inherit config system; }
, pkgs ? iohkLib.pkgs
}:
{
# your builds go here
}
The config
and system
arguments above are needed when building for
other systems. They have default values, and should be passed through
to iohk-nix
.
Now set up ./nix/iohk-common.nix
, which is pure boilerplate:
let
spec = builtins.fromJSON (builtins.readFile ./iohk-nix.json);
in import (builtins.fetchTarball {
url = "${spec.url}/archive/${spec.rev}.tar.gz";
inherit (spec) sha256;
})
And create iohk-nix.json
. You will need nix-prefetch-git
(get it
with nix-env -iA
or nix-shell -p
). The --rev
option defaults to
the HEAD of the master
branch.
$ nix-prefetch-git https://github.com/input-output-hk/iohk-nix [ --rev master ] | tee ./nix/iohk-nix.json
To get the latest version of iohk-nix
, update the iohk-nix.json
file:
$ nix-prefetch-git https://github.com/input-output-hk/iohk-nix | tee ./nix/iohk-nix.json
Some things may have changed which could break your build, so refer to the ChangeLog.
The documentation needs to be updated.
If you have updated your project's Stackage LTS version, then the compiler version may also have been increased.
It's possible that the nixpkgs
used in iohk-nix may not have have
that version of GHC, and you will get an error such as:
error: attribute 'ghc864' missing
In this case, update the iohk-nix
revision to the latest
available. The nixpkgs version may also need to be bumped in
iohk-nix
.
The gotchas folder is dedicated to typical Nix errors encountered while developing with Haskell and Nix. The hope is developers will add Nix related problems they've encountered and solved to this folder.
- Gotcha 1 - attribute
unbuildable
missing (win32/unix dependency issues)
Please document any change that might affect project builds in the ChangeLog. For example:
- Bumping
nixpkgs
to a different branch. - Changing API (renaming attributes, changing function parameters, etc).
- Bumping the
haskell.nix
version.