I do not install a toolchain on a machine any more. I describe one in the repository, and enter it.
That decision has a cost and a payoff that are easy to state. The cost is four files per project and a little discipline about pins and hashes. The payoff is that a checkout from three years ago still builds, that CI runs the same commands I run, and that a contributor does not need a paragraph of installation instructions before the first maak check. There is no “works on my machine” left to say, because the machine is in the tree.
This post is about the arrangement I use in ~/Hacking/: three Guix files, one Nix flake, a pinned channel set, and a signed Guix channel that packages the whole collection. It is also about why both Guix and Nix, since the honest answer is not “one won”.
The three Guix files #
Every project keeps the same three files, and each answers a different question.
guix.scm answers “what is this program?” #
It is a package definition, the same kind of thing the Guix repository itself carries: a name, a version, an origin, a build system, inputs, a synopsis, a description and a licence. What makes it a development file rather than a release recipe is the source:
(define %source-dir (dirname (current-filename))) (define-public maak (package (name "maak") (version "dev") (source (local-file %source-dir #:recursive? #t #:select? (git-predicate %source-dir))) (build-system guile-build-system) ;; ... inputs, synopsis, description, licence, and the phases that ;; install the launcher and the manual page. ))
The local-file with git-predicate packages the working tree while leaving out everything Git ignores, so an untracked build directory does not become part of the source. The version is "dev" because this is the checkout, not a release: the release tag gets its own version from the tag. The rest of the file is ordinary Guix, with the additions a real program needs – the launcher, the completions, the manual page, the help screen installed where the program looks for them, and the interpreter paths rewritten to the store.
That file is what makes guix build -f guix.scm work from the checkout, and what the Guix channel later turns into a released package.
manifest.scm answers “what do I need to work on it?” #
It is the development environment, and it is deliberately not the package’s inputs. It holds the tools a person uses, not the libraries the program links:
(packages->manifest (list texinfo
darkhttpd
watchexec
emacs-no-x
librsvg
font-dejavu
node))
That is the site’s manifest, and every entry has a reason written beside it in the file. librsvg provides rsvg-convert, which draws the per-article social cards, and font-dejavu is what it draws the text with, so both have to be declared rather than hoped for. node runs the pinned esbuild and tsc from package.json. darkhttpd serves the result, watchexec rebuilds on a change, emacs-no-x builds the site, and texinfo is there for the manual pages.
The rule I follow is that a tool which is needed to run a task belongs in the manifest, whether or not it is a build dependency of the package. The task list and the manifest should describe the same machine.
One tool is in every layer: sift, the formatter, linter and language server for Scheme, Emacs Lisp and Common Lisp. It is in the channel and in the manifests of the Lisp projects that use it; the editor starts sift lsp, maak fmt runs sift format --write, and CI runs sift ci. Because it is Guile 3.0 and the standard library with no C dependency, a checkout, a pinned shell and a Guix package are the same program with no build step – guix install sift from the channel gives the editor and the pipeline the executable they both run.
channels.scm answers “which Guix, exactly?” #
This is the file that makes the other two reproducible:
(list (channel
(name 'guix)
(url "https://git.guix.gnu.org/guix.git")
(branch "master")
(commit
"ecbebf72c5f59f96aed8d18cfdd0097d7230a1e2")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))A commit and an introduction: the commit says which Guix, and the introduction says which history is trustworthy and from which commit the signatures start. Guix verifies the commits it fetches against that introduction, so a moved branch or a rewritten history is an error rather than a silent upgrade.
Projects that also need my own packages add the channel:
(channel (name 'jointhefreeworld) (url "https://github.com/jjba23/guix-jointhefreeworld") (branch "trunk") (commit "bd5facf3bc6fbc3726ce3df6f599749236ae3f87") (introduction (make-channel-introduction "b0ac3f05075d7959860fc9e1db5871acddea3986" (openpgp-fingerprint "83BC 6E1C 8726 B8C2 97F8 D16E 24F4 6738 CE11 4AF6"))))
Three files, three questions, and the fourth question – “which commands?” – is the Maak file.
The pinned shell is the only shell #
The point of channels.scm is not documentation. It is an entry point:
guix time-machine --channels=channels.scm -- shell -m manifest.scm
That command gives a shell with the manifest’s packages, built by the Guix at the pinned commit, on whatever distribution the machine happens to run. The shell is not “close enough” to the environment the project was developed in; it is the environment, as far as any two machines can have the same one.
I could write that command in every README and every CI file. Instead, Maak wraps it:
(define (js-run args) "Run ARGS with the pinned Node, which is where the js tools get a runtime." (time-machine-manifest-shell args #:verbose? #t))
So maak lint-js, maak test-js and maak build-js do not need Node on the machine. maak build does not need an Emacs of the right version on the machine. maak hot-reload runs watchexec from the manifest. The site build is the clearest case:
(time-machine-manifest-shell (list "emacs" "-Q" "--batch" "-l" "./jointhefreeworld-site.el" "--funcall" "jfw/publish") #:env (list (~ "CI=~a" (if ci? "true" "false"))) #:verbose? #t)
-Q is not decoration. It means the build does not read my personal Emacs configuration, so a package I happen to have installed cannot change the output. The build’s environment comes from the manifest and nothing else. That is the difference between a build that is reproducible and one that merely runs.
Why pin a commit instead of installing Guix and moving on #
Because “the latest Guix” is four different environments in a week, and because the pin is reviewable. A change to channels.scm is a one-line diff that says “the whole project moves to this Guix”, and git log can answer when it moved and why. A guix pull answers none of that.
There is also a harder reason. The GTK4 programs need Rust 1.92. Guix 1.5 ships 1.85. An unpinned build stops in the build phase with the crates’ own minimum-supported-Rust message, which is a good error but a wasted afternoon. The pinned revision in the channel has the toolchain those programs were written against. Pinning is not nostalgia; it is the only way to build software whose requirements are ahead of the distribution’s default.
A signed channel is a package collection with a history #
guix-jointhefreeworld is a Guix channel: a package collection Guix can pull alongside its own. It is not a fork of Guix and not an operating system. It carries the Guile libraries the projects share, the command-line programs, the Emacs packages, the GTK4 desktop programs, and the site builder.
The part that matters here is that the channel is authenticated. The channel’s own .guix-authorizations names the keys allowed to sign its commits, and the introduction names the commit where the trust starts. guix pull verifies the history from that point, and guix git authenticate can be run by hand. A channel that is merely downloaded is a convenience; a channel with an authenticated history is a supply-chain statement.
The maintenance loop is Maak tasks:
| Task | What it does |
|---|---|
maak build |
Builds one package, or every package in the manifest, at the pinned revision. |
maak lint |
Lints every package; reaches the network for the updater and CVE checks. |
maak check |
Lints offline, builds every package, then authenticates the history. This is the gate. |
maak outdated |
Runs guix refresh with the generic-git updater, comparing each package with its repository’s tags. One fetch per package, no token, no rate limit. |
maak shell |
Opens a shell with every package in the channel. |
maak authenticate |
Verifies the signatures from the introduction to HEAD. |
maak publish |
Pushes the authenticated trunk and the keyring branch. |
Two details from that file are worth stealing. maak check uses guix lint --no-network before the build, so a CI run does not depend on an updater’s network being up; the network-touching lint is a separate task a person runs. And the certificate handling in maak outdated is explicit: guix refresh reads tags through libgit2, which verifies repository certificates against the system trust store. A Guix installed on another distribution may have no /etc/ssl/certs to offer it, so the task builds Guix’s nss-certs and points SSL_CERT_DIR at it. That is the kind of thing that makes a tool feel broken until somebody writes down why it is not.
The Nix side #
Nix is not a second hobby. It is the compatibility surface: some users and CI systems already have flakes, some are on NixOS, and some are on macOS where Guix is not an option. So every project also carries a flake, built from the same source and the same tests.
The flake is thin on purpose. Maak’s is a good example:
{
description = "Maak - The infinitely extensible command runner à la Make (Guile Scheme)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = system: nixpkgs.legacyPackages.${system};
in
{
packages = forAllSystems (system:
let
pkgs = pkgsFor system;
in
{
maak = pkgs.callPackage ./default.nix {};
default = self.packages.${system}.maak;
});
apps = forAllSystems (system: {
maak = {
type = "app";
program = "${self.packages.${system}.maak}/bin/maak";
};
default = self.apps.${system}.maak;
});
devShells = forAllSystems (system:
let
pkgs = pkgsFor system;
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.maak ];
packages = with pkgs; [
guile
coreutils
util-linux
];
};
});
};
}
The derivation is in default.nix (or package.nix for the Rust and GTK programs), and the flake only exposes it. nix build .#maak, nix run .#maak -- --list, nix develop and nix profile install all work from that one file.
The same discipline as the Guix side applies, in a different language:
- The version is read from the source, not repeated. Maak’s
default.nixreadssrc/maak/version.scmand parses the version out of it, so the derivation cannot fall behind the program. Lambdock goes the other way:package.nixis the version source, andmaak sync-versionwrites that version into the PKGBUILD, the RPM spec, the Void template, the AppStream metadata andCargo.toml. - The dev shell is the tools, not the package.
inputsFrompulls in the package’s own inputs; the extra packages are what a person needs:clippy,rustfmt,rust-analyzer,ccls,watchexec,xvfb-runandrustPlatform.rustLibSrc. That last one is what makes the editor show the standard library’s signatures and documentation instead of guesses. A dev shell is a working environment, not a smaller build. - Platforms are declared once. The GTK4 and Wayland programs stay on Linux; each project’s expression says so, and the aggregate reads it from there rather than from a list kept by hand.
One flake for the whole collection #
nix-jointhefreeworld is the aggregate: eighteen programs, seven Guile libraries, five Emacs packages, and the five Guile dependencies nixpkgs does not have yet. One flake.lock pins every project, so a consumer gets one revision known to build together instead of thirty-five URLs to keep in step.
Two design choices make it maintainable. Each package is built by the expression in its own repository – the Guile projects’ default.nix, the elisp projects’ default.nix next to the .el file – so the aggregate never restates how something is built and the two cannot drift apart. And the five missing dependencies are built from branches of a nixpkgs fork until the branches are merged, which is the honest way to carry a patch: visible, pinned, and easy to delete when upstream takes it.
nix flake check builds the whole set and runs every Emacs ERT suite. That is the Nix-side equivalent of maak check, and it is deliberately not a rewritten test suite: the tests come from the projects.
How the two stay in step #
The two ecosystems could easily become two projects. The arrangement that prevents it is simple:
| Question | Guix answer | Nix answer |
|---|---|---|
| What is the package? | guix.scm |
default.nix or package.nix |
| What is the environment? | manifest.scm |
the flake’s devShell |
| Which dependencies, exactly? | channels.scm + content hashes |
flake.lock + fixed-output hashes |
| What proves it works? | maak check in the pinned shell |
nix flake check |
| How is a release made? | maak release, then the channel updates |
maak release, then the flake lock updates |
| Who is it for? | my daily environment, and Guix users | NixOS, CI, macOS, and people who already have flakes |
The rule underneath the table is that neither side owns the build logic. The build steps live in the project – its Makefile-free task file, its xtask, its cargo build, its Guile modules – and both package expressions call them. When a build step changes, it changes once, and the two packagers pick it up.
That is also why the release ritual is one task rather than two. maak release writes the version into every file that carries a copy, writes the changelogs, runs the gate, commits, tags and pushes. The Guix channel follows the tag; the flake lock follows the tag; the distribution recipes follow the tag. If the copies disagree, maak version-check fails before a release can be cut.
Traps I have already paid for #
- A pin that never moves is a fossil. The channel commit and the flake lock need deliberate updates, or the project is developed against a Guix from last year. I treat both as part of a release, not as background noise.
- Hashes are the price of purity. A source tarball that changes its hash is a build that fails, which is the point. The checksum in a distribution recipe has to be refreshed after the archive is published; no task can know it before then.
- Network in a build is a bug.
guix buildandnix buildrun in environments where the network is not there. A task that downloads during a build works on my machine and fails everywhere that matters. Fetch in a development task, or declare the input. - Vendored crates need care.
cargo build --offline --lockedis the rule, and a clean step that deletes*.origfiles can break the vendor tree’s checksums unless it excludes it. That is a one-line fix with an afternoon of confusion behind it. - Certificates are part of the environment. The libgit2 trust-store problem above is not Guix’s fault; it is what happens when a package manager runs on a system whose certificate layout it does not own. Write the workaround down.
- Two ecosystems double the surface. The aggregate and the channel are both green or the release is not done. That is a real cost, and the only reason to pay it is that the users are on both sides.
Start smaller than I did #
If you are starting from nothing, the order that worked for me is:
- Write
manifest.scm. One file, one list of tools, andguix shell -m manifest.scmgives a colleague the same environment. This is the highest value per line of the three. - Add
channels.scmwith a pinned Guix commit. Now the manifest means the same thing next month. - Add
guix.scmwhen you wantguix build -f guix.scm, or when you want the project in a channel. Do not write it first; a package definition is a promise about installation, and the manifest is a promise about development. - Add
flake.nixlast, when somebody actually needs Nix. It is cheap once the build is already described by one command.
The test of the arrangement is not that the files exist. It is that a fresh machine with Guix, Git and a network can run one command from the README and get a working build, and that the same command in CI gets the same answer. Everything else is decoration.
I use both Guix and Nix because different people arrive with different tools, and because a second implementation is a second check on whether the first one described the software or only described one packager’s habits. Guix is where I live; Nix is where the project has to be a good guest. Keeping both honest is the same job as keeping the code honest: say what you depend on, pin it, and let a check fail when the story stops being true.
The rest of this series: developing inside Emacs, the task file that drives all of this, and packaging the results for the distributions.