Nix Progress (Part 2)
I have made more progress on Nix configuration since yesterday’s Nix Progress blog entry.
GHC 9.0.1
I made one more attempt to start a shell with GHC 9.0.1 using the
HEAD
revision of nixpkgs
yesterday, and it
worked! 4d4fdc32
nixpkgs
Revisions
Divam’s TTC pull request uses the following revisions:
- Thunk:
nix/default
- Revision: bed08131cd29a85f19716d9351940bdc34834492
- Source: nix-versions revision for GHC 8.10.3
- Usage: default,
nix-gitignore
- Thunk:
nix/ghc901
- Revision: de7e0f7dee2deeda620e0c940362e2e63ad5f6bf
- Source:
HEAD
when pull request started? - Usage:
ghc884
,ghc8104
,ghc901
- Thunk:
nix/ghc865
- Revision: 2d9888f61c80f28b09d64f5e39d0ba02e3923057
- Source: nix-versions revision for GHC 8.6.5
- Usage:
ghc865
- Thunk:
nix/ghc844
- Revision: 6a80140fdf2157d1a5500a04c87033c0dcd6bf9b
- Source: nix-versions revision for GHC 8.4.4
- Usage:
ghc822
,ghc844
Through experimentation, I determined why the
nix/default
revision is used for
nix-gitignore
. When older revisions are used, loading the
Nix expression results in an error. I suspect that this is due to an API
change. The issue is avoided by using a recent revision for
nix-gitignore
and using a possibly different revision for
Haskell packages. I do not really understand why, but the default must
be compatible with GHC 9.0.1 or the build of the GHC 9.0.1 shell fails!
I think that using a different revision might have been the
cause of build failures yesterday.
Some revisions are used for more than one compiler version. For example, GHC 8.2.2 works fine using the nix-versions revision for GHC 8.4.4, so the nix-versions revision for GHC 8.2.2 is not used. I think that the reason for doing this is to minimize the number of packages that have to be installed. Nice!
I updated the revision for GHC 9.0.1 to the one that was successful
for me. Since I have had so many failures when using arbitrary
revisions, I am using the nix-versions
revision for GHC 8.10.4 with ghc8104
and
ghc884
.
- Thunk:
nix/default
- Symbolic link to
ghc-9.0.1
- Usage: default,
nix-gitignore
- Symbolic link to
- Thunk:
nix/ghc-9.0.1
- Revision: 4d4fdc329285e0d0c1c1a2b65947d651b8ba6b29
- Source:
HEAD
when I tested the shell - Usage:
ghc901
- Thunk:
nix/ghc-8.10.4
- Revision: c92ca95afb5043bc6faa0d526460584eccff2277
- Source: nix-versions revision for GHC 8.10.4
- Usage:
ghc884
,ghc8104
- Thunk:
nix/ghc-8.6.5
- Revision: 2d9888f61c80f28b09d64f5e39d0ba02e3923057
- Source: nix-versions revision for GHC 8.6.5
- Usage:
ghc865
- Thunk:
nix/ghc-8.4.4
- Revision: 6a80140fdf2157d1a5500a04c87033c0dcd6bf9b
- Source: nix-versions revision for GHC 8.4.4
- Usage:
ghc822
,ghc844
Refactoring
Once I got things working, I could refactor and make improvements.
I created shell-VERSION.nix
files to make it easy to run
a Nix shell with the specified compiler version. Each file looked like
the following:
import ./shell.nix {
pkgs = import ./nix/ghc-9.0.1 {};
compiler = "ghc901";
}
Unless using the default, both pkgs
and
compiler
need to be specified as arguments to
shell.nix
, and the specified compiler
must be
supported by the specified pkgs
. To improve this, I put the
mapping from compiler
to pkgs
inside of
shell.nix
. Since only the compiler needs to be specified,
it is easy to specify the argument using nix-shell
and all
of the shell-VERSION.nix
files can be removed.
The nix-thunk
software is nice, but it is overkill for this simple use case. I
refactored shell.nix
to define the nixpkgs
revisions directly. This greatly simplifies the configuration, allowing
me to remove the whole nix
directory. It greatly simplifies
maintenance as well.
What’s Next?
I will work on the Nix configuration for LiterateX next. The configuration will be a bit different because the project includes an executable as well as a library. I will also work on the Nix configuration for the animation, which has system dependencies.
Once that is done, I will work on the Nix configuration for the other projects. I expect/hope that it will be easy after doing so for both TTC and LiterateX.
If there are no recommendations for further change to the Nix configuration, I will make minor releases for all projects.