Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While Nix derivations, which we use to package up the programs, produce mostly reproducible builds via
nix-build
, the Nix ecosystem increasingly seems to be moving in the direction of flakes12, which provide some conveniences and even more reproducible builds by e.g. locking the nixpkgs revision.Note
Flakes are another, higher-level notion of package, that in of itself only define a set of inputs (dependencies) and outputs (an attribute set)1. By convention, however, keys such as
packages
andapps
are used to declare derivations and executables in the output, such that commands likenix build
andnix run
know what to work with.For this reason we will migrate this repo to flakes too. Specifically:
nix run
to build and run the programderivation.nix
using nixpkgs-style dependency injection (i.e.{ stdenv, ...}: ...
instead of{ pkgs }
).callPackage
3 instead ofimport
, however, and also means that we can no longer build the days with the legacynix-build
command. In principle, one could write a wrapper.nix
that invokescallPackage
, like the flake does4, but to keep things uniform, we will only provide a flake for now.b-compiler
orpakcs
) from the flake, which are now also declared in the nixpkgs-style format3.Footnotes
A great write-up of Nix flakes: https://www.reddit.com/r/NixOS/comments/131fvqs/can_someone_explain_to_me_what_a_flake_is_like_im/ ↩ ↩2
Another great write-up: https://christine.website/blog/nix-flakes-1-2022-02-21/ ↩
A nice explanation and motivation of
callPackage
: https://summer.nixos.org/blog/callpackage-a-tool-for-the-lazy/ ↩ ↩2A good walkthrough of (non-flake) Nix packaging, along with an extensive example can be found here: https://unix.stackexchange.com/a/717169/556223 ↩