Track .envrc + make postgres scripted test work on NixOS#5
Conversation
Track the .envrc with `use flake` so contributors with direnv + nix-direnv get the devshell automatically on cd, without having to author .envrc themselves. Closes #4 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zonky's bundled generic-Linux Postgres binaries can't run on NixOS, so `sbt scripted` fails locally even though CI (Ubuntu) is fine. The flake devshell now exports NOMAD_PG_TARBALL pointing at an XZ tar of pkgs.postgresql (bin, lib, share). When set, the test feeds that through a custom PgBinaryResolver and overrides unix_socket_directories to $TMPDIR (nix postgres defaults to /run/postgresql, absent in the sandbox). Without the env var, behaviour is unchanged — CI keeps working as-is. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Tracks a repo-level .envrc to auto-load the Nix flake devshell via direnv, and adjusts the clean-and-migrate-postgres sbt scripted test to optionally use a Nix-provided Postgres tarball on NixOS (avoiding zonky’s bundled generic Linux binaries).
Changes:
- Add tracked
.envrc(use flake) and stop ignoring it in.gitignore. - Extend
flake.nixdevshell to build/exportNOMAD_PG_TARBALLcontaining a tar.xz ofpkgs.postgresqlin the layout expected by zonky. - Update the scripted test
Main.scalato useNOMAD_PG_TARBALLwhen set and overrideunix_socket_directoriesto the JVM temp dir.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
sbt-plugin/src/sbt-test/nomad/clean-and-migrate-postgres/src/main/scala/Main.scala |
Adds env-var-controlled Postgres binary override + socket dir override for NixOS compatibility. |
flake.nix |
Builds a Postgres tarball and exports NOMAD_PG_TARBALL in the devshell. |
.gitignore |
Stops ignoring .envrc so it can be tracked. |
.envrc |
Enables direnv+nix-direnv to auto-load the flake devshell. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The comment said "point it at the data dir" but the code uses the JVM temp dir. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Jhin🤖 says: Review finding: This PR makes the repo flake-driven for everyone by tracking I validated the NixOS-specific Postgres scripted test change itself and it looks sound; the blocker is portability of the newly shared flake setup. I would either add Darwin outputs in this PR or avoid making |
Extends supportedSystems with x86_64-darwin and aarch64-darwin so macOS contributors using nix-darwin can enter the same direnv/flake devshell. The NOMAD_PG_TARBALL override path in the postgres scripted test is platform-agnostic, so the same Nix-built tarball workaround works on Darwin too (harmless there since zonky's bundled macOS binaries would also load natively).
|
Sylas🤖 says: Valid finding — confirmed with @NovaMage that macOS contributors do use this repo via nix-darwin. Fixed in b7f09fe by adding The |
Summary
.envrc(withuse flake) so contributors with direnv + nix-direnv get the devshell auto-loaded oncd, rather than authoring the file themselves or runningnix developmanually.nomad/clean-and-migrate-postgresscripted test on NixOS. zonky's bundled generic-Linux Postgres binaries fail to load there ("NixOS cannot run dynamically linked executables intended for generic linux environments"). The devshell now exportsNOMAD_PG_TARBALLpointing at an XZ tar ofpkgs.postgresql(bin,lib,share); the test feeds that through a customPgBinaryResolverand overridesunix_socket_directoriesto$TMPDIR(nix postgres defaults to/run/postgresql, which doesn't exist in the sandbox).EmbeddedPostgres.start()runs as before.Closes #4.
Test plan
sbt clean scripted docpasses locally on NixOS (22/22 scripted tests + doc).🤖 Generated with Claude Code