Skip to content

Conversation

@thomashoneyman
Copy link
Member

When setting up a new machine and looking at the Nix setup we have I noticed a lot of quirkiness, nonstandard patterns, and relying on one-off little utilities like slimlock (thankfully in #701 we moved to mkSpagoDerivation from our homegrown purix). We also have some essentially dead code in Nix modules like run-vm, as AFAIK no one actually deploys the app to a VM and issues requests against it.

So I took a pass through everything to update to current best practices, improve performance especially in the dev shell, and make the codebase easier for contributors to work with. Here are some high-level changes:

  • The flake.nix is broken into a few smaller modules (overlays, lib) with the integration test extracted out, so itas more like 250 lines instead of 900 lines
  • Switched to the standard buildNpmPackage from the custom slimlock tool
  • Got rid of the separate GitHub spago test script, as we can just run it as part of the overall nix flake check checks like everything else is
  • Cleaned up the wiremock and git mock implementations and added comments to document the integration test so it's easier to understand why we have all this infrastructure for it
  • Removed unnecessary legacy support (shell.nix, flake-compat) and dropped the test VM setup
  • Included .envrc for developers using direnv — I personally need this, don't want to commit it on all fresh clones, and I think @f-f and I both already were on it

The codebase works the same as before, all the same commands (minus running the test VM), just a better setup internally.

this was already used by several developers, this just makes it
official
this also allows us to remove our single 'spago test' invocation
in a github workflow, so all CI checks are in the Nix checks for
Garnix to execute

while i was at it, i removed the nix flakes wrapper, shell.nix,
and flake-compat inclusions as at this point pretty much everyone
is on a flake-compatible version of Nix
slimlock was the homegrown npm dependency builder from ps-overlay
from before when buildNpmPackage was a suitable choice for the
registry, but at this point it's well-suited to be the standard
choice for us.
our homegrown nix setup has diverged quite a bit from modern
best practices and is hard to read. it also included some
unnecessary helpers (like run-vm to work on a local vm) which
we can remove.

this change overhauls the full setup while maintaining the
existing tests to make it simpler, more performant, and more
usable for contributors.

the deployments are still simple ('colmena apply').
@thomashoneyman thomashoneyman requested a review from f-f December 2, 2025 18:05
Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks!

I would like to eventually get rid of the Nix VM (and replace it with something more agnostic, e.g. docker), but this is a good start 👏 👏

@f-f f-f merged commit 20416f0 into master Dec 2, 2025
17 checks passed
@f-f f-f deleted the trh/nix-refactor branch December 2, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants