Repository navigation
feat: add a Nix flake - #247
Conversation
umputun
left a comment
There was a problem hiding this comment.
lgtm. Matches the #230 recipe - ldflag hits the real main.revision symbol, license/vendorHash/eachDefaultSystem all check out, and the three lock inputs are official upstreams.
two notes, neither blocking:
-
couldn't run
nix buildhere to confirm it actually builds. Worth a quicknix build+nix run . -- --versionbefore merge -go.modisgo 1.26with notoolchaindirective, so the pinned nixpkgspkgs.gohas to be >= 1.26 or the sandboxed build hard-fails with no toolchain fallback. -
version = self.shortRev or ...makesrevdiff --versionprint a bare commit hash on nix builds (devfrom a non-git tarball) instead of thetag-hash-datefrom goreleaser/make. Fine to leave, pure flakes can't read git tags cleanly, just flagging.
Summary
Adds a minimal
flake.nix(and itsflake.lock) so revdiff can be built, run, and hacked on through Nix:nix run github:umputun/revdiff -- <args>runs the TUI with no manual Go toolchain setupnix buildproduces therevdiffbinary atresult/bin/revdiffnix developdrops into a shell with Go availableWhy this matters
Requested in #230, where you confirmed you were "happy to take a minimal flake.nix as a PR" and sketched the exact recipe this change follows. Packaging revdiff as a flake lets Nix users install and pin it alongside the rest of their tooling, and
nix run github:umputun/revdiffgives a zero-install way to try it.The flake stays in lockstep with the existing build:
buildGoModulewithvendorHash = nullbuilds straight from the committedvendor/tree, so the build needs no network access and tracksgo mod vendor.CGO_ENABLED = 0andldflags = [ "-s" "-w" "-X main.revision=${version}" ]mirror the Makefile, sorevdiff --versionis populated../appis renamed torevdiff, andmeta.mainProgram = "revdiff"makesnix runresolve it.Per your request the change is limited to
flake.nix+flake.lock, with no CI changes and nixpkgs packaging left to the community.Testing
go build ./...passes against the vendored tree.flake.lockpinsnixpkgs(nixpkgs-unstable),flake-utils, and flake-utils'ssystemsinput to released revisions; the pinned nixpkgs defaults to Go 1.26, matchinggo 1.26ingo.mod.doCheck = falseskips the Go test phase during the build, since some tests (e.g. VCS detection) expect a.gitworking tree that Nix's source copy omits.Fixes #230