diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 708ff12..0e8900d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -48,5 +48,20 @@ brews: name: homebrew-tap token: "{{ .Env.TAP_GITHUB_TOKEN }}" +nix: + # Publishes a Nix derivation that installs pre-built binaries to + # the mickamy/nur-packages repository on each release. + # Prerequisites: + # 1. Create the mickamy/nur-packages repository (NUR-compatible layout). + # 2. Add "install nix" step to the release workflow so nix-hash is available. + - name: sql-tap + homepage: https://github.com/mickamy/sql-tap + description: Watch SQL traffic in real-time with a TUI + license: mit + repository: + owner: mickamy + name: nur-packages + token: "{{ .Env.TAP_GITHUB_TOKEN }}" + changelog: sort: asc diff --git a/README.md b/README.md index 68791da..a5d54cf 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,35 @@ cd sql-tap make install ``` +### Nix + +**Using the flake directly** + +```bash +nix profile install github:mickamy/sql-tap +``` + +**In a `devenv.sh` project** + +Add `sql-tap` as a flake input in `devenv.yaml`: + +```yaml +inputs: + sql-tap: + url: github:mickamy/sql-tap +``` + +Then reference it in `devenv.nix`: + +```nix +{ inputs, pkgs, ... }: +{ + packages = [ + inputs.sql-tap.packages.${pkgs.system}.default + ]; +} +``` + ### Docker **PostgreSQL** diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f7d4e14 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Real-time SQL traffic viewer — proxy daemon + TUI / Web client"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { self + , nixpkgs + , flake-utils + }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + version = self.shortRev or self.dirtyShortRev or "dev"; + in + { + packages = { + sql-tap = pkgs.buildGoModule { + pname = "sql-tap"; + inherit version; + src = pkgs.lib.cleanSource self; + subPackages = [ "." "cmd/sql-tapd" ]; + + # When go.mod or go.sum changes, update this hash by running: + # nix build 2>&1 | grep "got:" | awk '{print $2}' + # and replacing pkgs.lib.fakeHash below with the output. + vendorHash = pkgs.lib.fakeHash; + + ldflags = [ + "-s" + "-w" + "-X main.version=${version}" + ]; + + meta = with pkgs.lib; { + description = "Watch SQL traffic in real-time with a TUI"; + longDescription = '' + sql-tap sits between your application and your database + (PostgreSQL, MySQL, or TiDB), capturing every query and + displaying it in an interactive terminal UI. Inspect queries, + view transactions, and run EXPLAIN — all without changing your + application code. + ''; + homepage = "https://github.com/mickamy/sql-tap"; + license = licenses.mit; + maintainers = [ ]; + mainProgram = "sql-tap"; + platforms = platforms.unix; + }; + }; + default = self.packages.${system}.sql-tap; + }; + } + ); +}