Skip to content

feat: add Nix flake for reproducible builds#100

Merged
timvw merged 6 commits into
mainfrom
feat/nix-flake-proper
Jul 6, 2026
Merged

feat: add Nix flake for reproducible builds#100
timvw merged 6 commits into
mainfrom
feat/nix-flake-proper

Conversation

@timvw

@timvw timvw commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a flake.nix / flake.lock so wt can be installed and run via Nix. Builds on @gitmpr's work in #99 (their three commits are preserved here) and folds in the review + codex findings from that PR.

nix run github:timvw/wt -- version      # run without installing
nix profile install github:timvw/wt     # install to profile

Changes on top of #99

  • Exclude the internal e2e main package (excludedPackages = [ "e2e" ]) so nix profile install produces only the wt binary, not a stray e2e orchestrator binary. Unlike subPackages, this keeps the full test suite in check scope.
  • Derive the version from the git rev (self.shortRev) instead of a hardcoded 0.1.29 that silently goes stale after each release (release binaries are still versioned by goreleaser from the tag; the flake has no access to tags).
  • Resolve bash via exec.LookPath in remove_cleanup_test.go instead of hardcoding #!/usr/bin/env bash, which removes the fragile postPatch shebang rewrite entirely and is robust in any sandbox.
  • Bundle git in the binary's runtime PATH via makeWrapper, since wt shells out to git at ~39 sites — the package now works even when git isn't otherwise installed.
  • Gate util-linux to Linux in nativeCheckInputs (it's unavailable on Darwin, where script(1) ships with the base system) so the Darwin systems from eachDefaultSystem evaluate.
  • Fix the NixOS/home-manager docs: pkgs.wt doesn't exist in nixpkgs; show a complete flake-input example. Also document that shell integration calls git and script(1) in the user's shell.
  • Add a maintainer note for refreshing vendorHash.

Test plan

  • go build ./... and the full go test ./... suite pass
  • nix build .#wtnot run locally (nix isn't installed on this machine); please confirm via CI or a nix-capable machine that the build + sandboxed checks pass on Linux and Darwin

Closes #99 (superseded).

Co-authored-by: gitmpr 89863774+gitmpr@users.noreply.github.com

gitmpr and others added 4 commits July 6, 2026 12:55
Adds flake.nix and flake.lock providing a Nix-native install path:

  nix run github:gitmpr/wt
  nix profile install github:gitmpr/wt

The build uses buildGoModule with vendorHash and injects the version
string via ldflags. Three sandbox quirks are handled explicitly:

- git, bash, util-linux in nativeCheckInputs so tests have git,
  script(1), and a bash binary reachable by absolute path
- postPatch rewrites #!/usr/bin/env bash in the runtime-generated test
  helper to an absolute nix store path, since /usr/bin/env is absent
  from the Nix build sandbox
- preCheck initialises a git repo in the source tree so tests that
  call git in the working directory (TestGetAvailableBranches,
  TestDefaultCmdRunsWithoutError) find a valid repository
- Exclude internal e2e main package so only the wt binary is built/installed
- Derive version from git rev instead of a hardcoded semver that goes stale
- Resolve bash via exec.LookPath in the cleanup test, dropping the fragile
  postPatch shebang rewrite
- Document flake-input usage for NixOS/home-manager (pkgs.wt does not exist)
- Add maintainer note for refreshing vendorHash
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 30.58%. Comparing base (447beb4) to head (e04ec33).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #100      +/-   ##
==========================================
+ Coverage   30.48%   30.58%   +0.10%     
==========================================
  Files          27       27              
  Lines        2805     2805              
==========================================
+ Hits          855      858       +3     
+ Misses       1864     1860       -4     
- Partials       86       87       +1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

timvw added 2 commits July 6, 2026 14:30
- Add a Linux 'nix' job to CI that runs `nix build .#wt` (which executes the
  sandboxed Go test suite) plus a version smoke test
- Add a Dockerfile + .dockerignore for reproducing the flake build locally
  without installing Nix (docker build -t wt-nix .)
- Pin Dockerfile base to the nixos/nix digest that was validated
- Pin nix-installer-action to the v22 release tag instead of @main
@timvw timvw merged commit 68b612b into main Jul 6, 2026
11 of 12 checks passed
@timvw timvw deleted the feat/nix-flake-proper branch July 6, 2026 19:57
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.

2 participants