IOHK Common Nix Code
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
- 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.
- A skeleton project demonstrating how to use iohk-nix and set up CI.
How to use in your project
How to update the
To get the latest version of
iohk-nix, update the
iohk-nix-src.json file in your project.
Download the JSON file from iohk-nix Buildkite, or run the following command:
$ nix-prefetch-git https://github.com/input-output-hk/iohk-nix | tee ./nix/iohk-nix-src.json
(You may need to
nix-prefetch-git package beforehand.)
Some things may have changed which could break your build, so refer to the ChangeLog.
How to use Haskell.nix and
Look in the "User Guide" section of the Haskell.nix Documentation.
After updating your Stackage LTS
If you have updated your project's Stackage LTS
version, then you may need to update the
iohk-nix revision in your
project. The error message you may see is:
error: This version of stackage.nix does not know about the Stackage resolver X.Y. You may need to update haskell.nix to one that includes a newer stackage.nix.
If updating the LTS, the compiler version may also have been
increased. Note that we maintain a patched GHC for cross-compiling to
Windows. The GHC version that you use needs to be supported by
iohk-nix. The error message in this case will be:
error: This version of Nixpkgs does not contain GHC x.y.z
In both of these cases, update the
iohk-nix revision to the latest
available using the instructions above.
Adding new GHC versions
To add support for a new GHC version in
iohk-nix, first update its
Nixpkgs version to one that provides that compiler, then work on
adding the version to
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
unbuildablemissing (win32/unix dependency issues)
- Gotcha 2 - more help with build problems
- Gotcha 3 - filtering sources
- Gotcha 4 - overriding version pins
When making changes to
Please document any change that might affect project builds in the ChangeLog. For example:
nixpkgsto a different branch.
- Changing API (renaming attributes, changing function parameters, etc).
- Bumping the
Also update the
skeleton project if necessary.