feat: add Nix flake for reproducible builds#99
Conversation
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
Nix flake packaging for wt. Builds on @gitmpr's #99 (their commits preserved) with review + codex fixes: exclude the internal e2e binary, version-from-git-rev, bash via LookPath, git bundled in runtime PATH, util-linux gated to Linux, corrected NixOS/home-manager docs. Adds a pinned Linux Nix CI job and a Dockerfile for local repro. Co-authored-by: gitmpr <89863774+gitmpr@users.noreply.github.com>
|
Thank you so much for this, @gitmpr! 🙏 Your flake was the foundation here — the sandbox workarounds (nativeCheckInputs, the git init in preCheck, the shebang handling) were spot on and did the hard part. We folded your commits into #100 (preserved with a #100 is merged, so I'll close this one — but the credit is yours. Really appreciate you adding Nix support! 🎉 |
Summary
flake.nixandflake.locksowtcan be installed via the Nix package managernix profile install github:timvw/wtor run directly withnix run github:timvw/wt-X github.com/timvw/wt/cmd.Version=<version>)Install
Sandbox notes
The full test suite passes without skipping any tests. Three Nix build sandbox quirks required explicit handling:
git,bash,util-linuxinnativeCheckInputs— tests needgitin PATH, a reachablebashbinary, andscript(1)(fromutil-linux), which thewtshell function uses to allocate a PTY for interactive commandspostPatchshebang rewrite —TestRemoveCleansUpResidualWorktreeDirectorygenerates a#!/usr/bin/env bashwrapper script at runtime, but/usr/bin/envis absent in the Nix sandbox; the patch rewrites it to an absolute nix store pathpreCheckgit init — the sandbox strips.gitfrom the source tree;TestGetAvailableBranchesandTestDefaultCmdRunsWithoutErrorcallgitin the working directory, sopreCheckinitialises a fresh repoTest plan
nix build .#wtpasses (all tests, no-shortflag)./result/bin/wt versionprintswt version 0.1.29