feat(packaging): add Nix derivation and flake#56
Conversation
- Add packaging/nix/package.nix derivation that fetches pre-built binaries for x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin - Add packaging/nix/versions.json with per-platform URLs and SHA256 hashes - Add packaging/nix/update.sh for nixpkgs r-ryantm bot compatibility - Add flake.nix with packages, default package, and overlay outputs - Add default.nix for non-flake nix-env/nix-build/nix-shell usage - Add update-nix job to release workflow that auto-updates versions.json after checksums are generated - Update README with Nix installation instructions - Add result symlink to .gitignore Closes #25
vmvarela
left a comment
There was a problem hiding this comment.
PR #56 Review — Nix derivation, flake, and CI automation
Overall this is well-structured and follows good patterns (the versions.json approach matching nixpkgs' ngrok). Below are findings organized by severity.
Critical Issues
1. default.nix + README: nix-env -iA sql-pipe -f URL will fail
default.nix returns a single derivation directly:
pkgs.callPackage ./packaging/nix/package.nix { }But the README instructs:
nix-env -iA sql-pipe -f https://github.com/vmvarela/sql-pipe/archive/master.tar.gz-iA sql-pipe expects the -f expression to evaluate to an attribute set containing a sql-pipe attribute. Since default.nix returns the derivation itself, this will fail with an error like error: attribute 'sql-pipe' missing.
Fix (recommended): Keep default.nix as-is and change the README to use -if (install from file):
nix-env -if https://github.com/vmvarela/sql-pipe/archive/master.tar.gzWarnings
2. flake.lock is missing
The PR adds flake.nix but no flake.lock. Without a committed flake.lock, every consumer will resolve nixpkgs to the latest revision at evaluation time, making builds non-reproducible. Run nix flake lock and commit the generated flake.lock. This is standard practice for all Nix flakes.
3. CI: GITHUB_TOKEN may not be able to push to master (release.yml:738)
The update-nix job uses the default GITHUB_TOKEN to git push directly to master. If branch protection rules are enabled on master (e.g., required reviews, status checks), this push will be rejected. Consider:
- Using a PAT or GitHub App token with bypass permissions
- Or pushing to a branch and auto-creating/merging a PR
4. CI: sed stripping is a no-op / dead code (release.yml:733)
sed -i 's/^ //' packaging/nix/versions.jsonThe YAML block scalar run: | already strips the common leading indent (10 spaces) from the script content. After YAML processing, the heredoc body has 0–4 spaces of indentation, not 10. The sed pattern (matching 10 leading spaces) matches nothing — it's a harmless no-op but dead code that adds confusion.
Fix: Remove the sed line entirely.
5. update.sh:2: common-updater-scripts is unused
The nix-shell shebang includes common-updater-scripts but the script never uses any commands from it (like update-source-version). Remove it from the shebang:
#!nix-shell -i bash -p curl jq6. Hash format: bare hex vs. SRI (versions.json)
versions.json uses bare hex SHA256 hashes. While this works, modern nixpkgs convention prefers SRI format (sha256-BASE64STRING=). Bare hex may produce deprecation warnings in newer Nix versions. Consider converting in both update.sh and the CI job with nix hash to-sri --type sha256 "$HEX_HASH".
Minor / Nits
7. dontFixup = stdenvNoCC.hostPlatform.isLinux — correct, add a comment (package.nix:37)
The logic is right: musl-static Linux binaries need no fixup; macOS needs the fixup phase for codesigning (especially on Apple Silicon). A brief inline comment explaining why would help future maintainers:
# Linux binaries are statically linked (musl) — no fixup needed.
# macOS binaries need the fixup phase for ad-hoc codesigning.
dontFixup = stdenvNoCC.hostPlatform.isLinux;Verified as Correct
stdenvNoCC— correct choice for pre-built binary installationdontPatchELF = true— correct for musl-static binarieslib.importJSON ./versions.json— resolves correctly in both flake and non-flake contextstesters.testVersion— verified the Nix source wraps the command with2>&1, so stderr output fromsql-pipe --versionis captured correctlypassthru.updateScript = ./update.sh— follows nixpkgs conventionmeta.platforms = builtins.attrNames versions— clever, dynamically derives platforms from JSON keysawkextraction in CI —awkdefault field separator handles the two-space separator insha256sumoutput correctlyjqinterpolation —\($ver)syntax is valid jq string interpolation.gitignoreentryresult— standard for Nix build outputs- Overlay definition — correctly uses
final(not_prev) forcallPackage forAllSystems+ flake structure — follows standard conventions- SHA256 hashes — all four hashes in
versions.jsonverified againstsha256sums.txtfrom the v0.2.0 release
Summary
| Severity | Count | Items |
|---|---|---|
| Critical | 1 | nix-env -iA won't work with current default.nix |
| Warning | 5 | Missing flake.lock, GITHUB_TOKEN push perms, dead sed, unused common-updater-scripts, bare hex hashes |
| Nit | 1 | Add comment explaining dontFixup logic |
The critical issue (#1) should be fixed before merge.
- Fix README: use nix-env -if (not -iA) since default.nix returns a derivation directly, not an attribute set - Remove dead sed commands in update-nix and update-scoop CI jobs (YAML block scalars already strip the heredoc indentation) - Remove unused common-updater-scripts from update.sh nix-shell shebang
- Move aur/PKGBUILD and aur/.SRCINFO to packaging/aur/ to align with chocolatey/, nix/, and winget/ under the packaging/ directory - Update PKGBUILD and .SRCINFO to v0.2.0 hashes (were stale at v0.1.0) - Remove dead `sed 's/^ //'` from the update-aur CI job; the heredoc uses a quoted delimiter so the strip was always a no-op (same fix applied to Nix/Scoop in PR #56) Closes #57
- Move aur/PKGBUILD and aur/.SRCINFO to packaging/aur/ to align with chocolatey/, nix/, and winget/ under the packaging/ directory - Update PKGBUILD and .SRCINFO to v0.2.0 hashes (were stale at v0.1.0) - Remove dead `sed 's/^ //'` from the update-aur CI job; the heredoc uses a quoted delimiter so the strip was always a no-op (same fix applied to Nix/Scoop in PR #56) Closes #57
Summary
packaging/nix/package.nix) that fetches pre-built binaries for Linux and macOS (x86_64 + aarch64)flake.nixenablingnix run github:vmvarela/sql-pipe,nix profile install, andnix shelldefault.nixfor non-flake compatibility (nix-env,nix-build,nix-shell)update-nixCI job that auto-updatesversions.jsonafter each releasepackaging/nix/update.shfor nixpkgsr-ryantmbot compatibilityInstallation
Design
versions.jsonpattern (same as nixpkgs'ngrokpackage) for clean separation of data and logicautoPatchelfHookneededupdate-nixCI job runs afterchecksums, downloadssha256sums.txt, and commits updatedversions.jsonback tomasterCloses #25