feat(nix): add flake packaging with CI build - #1037
Open
jairbj wants to merge 3 commits into
Open
Conversation
Adds a Nix flake exposing the pad binary as packages.default (buildGoModule + importNpmLock for the embedded SvelteKit UI), a devShell, and flake checks (package build with `go test ./...`, plus a `pad --version` smoke test). nix/package.nix is written nixpkgs-submission-ready (no flake-specific inputs) so it can later be adapted for pkgs/by-name. Also adds a GitHub Actions workflow that runs `nix flake check` and `nix build` on push/PR, and documents `nix run` / `nix profile install` / `nix develop` in the README.
ValidateWebhookURL does a real net.LookupIP as an SSRF guard, and four TestValidateWebhookURL subtests exercise that path against example.com. That works fine in CI (real network) but fails under a properly sandboxed Nix build (no network), which is what real users hit. Skip just those subtests; the rest of the package's tests (invalid schemes, private-IP rejection, etc.) need no network and keep running.
…pots TestWebhookSecret_MaskedExceptOnCreate/RejectsReservedPrefix and the MCP HTTPHandlerDispatcher integration test create real webhooks through the handler, which calls ValidateWebhookURL's net.LookupIP SSRF guard. That needs DNS, which is unavailable in a sandboxed Nix build (and any other network-less test runner). Switch to a literal public IP, same fix already applied in handlers_webhook_token_idor_test.go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds Nix flake packaging for
pad, with an automated CI build.flake.nix— exposespackages.default/pad(the binary),apps.default(
nix run), adevShells.default(Go + Node pinned to the same versionsCI uses), and
checks(package build +pad --versionsmoke test).nix/package.nix—buildGoModule+importNpmLockderivation, writtennixpkgs-submission-ready (no flake-specific inputs). Composes the
SvelteKit build and the Go build via
postPatchso//go:embed all:web/buildinembed.gohas real files to embed..github/workflows/nix.yml— runsnix flake check+nix buildonevery push/PR, following the repo's existing SHA-pinned Actions
convention.
README.md— documentsnix run/nix profile install/nix develop.internal/server/handlers_webhooks_secret_test.go,internal/mcp/dispatch_http_routes_extras_test.go): swapped a couple ofexample.comwebhook URLs for a literal IP, matching the pattern alreadyused in
handlers_webhook_token_idor_test.go.ValidateWebhookURLdoes areal DNS lookup as an SSRF guard, which fails under Nix's sandboxed
(network-less) build — same fix, extended to the two spots that still hit
it.
How to test
nix build github:PerpetualSoftware/pad(once merged), or from thisbranch:
nix build .#default./result/bin/pad --version/--helpnix flake check— builds the package (which runsgo test ./...incheckPhase) and a version smoke testChecklist
make buildpassesmake testpassestweaks preserve existing coverage, just swap the URL literal