Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ jobs:
fi
echo "clean: no EXPLAIN ANALYZE"

nix:
name: nix build
# vendorHash changes with every dependency bump, so this job is
# informational — a red nix build must not block an otherwise green PR.
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix build .#pgbot
# proves the ldflags version stamp reached the packaged binary
- run: ./result/bin/pgbot --version | grep -q 'pgbot version 0\.'

build:
name: build ${{ matrix.goos }}/${{ matrix.goarch }}
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pgrun_metrcis2.mp4

# npm packaging build output (assembled by npm/build.mjs)
npm/staging/

result
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

outputs =
{ self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems =
f:
nixpkgs.lib.genAttrs systems (
system:
f (
import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
}
)
);
in
{
overlays.default = final: prev: {
pgbot = final.callPackage ./package.nix { };
};

packages = forAllSystems (pkgs: rec {
pgbot = pkgs.pgbot;
default = pgbot;
});

devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
go_1_27
golangci-lint
];
};
});
};
}
44 changes: 44 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
lib,
buildGoModule,
fetchFromGitHub,
go_1_27,
}:
(buildGoModule.override { go = go_1_27; }) (finalAttrs: {
pname = "pgbot";
version = "0.8.1";

src = fetchFromGitHub {
owner = "pgrundev";
repo = "pgbot";
tag = "v${finalAttrs.version}";
hash = "sha256-QJWJTSS92g7Ay2r5yckbRX5/JOUIBDTKGXpEzerZyKI=";
};

vendorHash = "sha256-iN6SE0ehjVVXkw8hHsUrCNXPV1Xchw6gxt92kVCQTV4=";

subPackages = [ "cmd/pgbot" ];

env.CGO_ENABLED = "0";

ldflags = [
"-X main.version=${finalAttrs.version}"
];

doCheck = true;

meta = {
description = "In-database observability for PostgreSQL";
longDescription = ''
pgbot is a read-only PostgreSQL observability CLI. A single static
binary connects with a read-only role, reads Postgres's own
statistics views, and prints findings-first health reports plus
diffs against previous runs. No agent, no external service, no
write privilege anywhere in the path.
'';
homepage = "https://github.com/pgrundev/pgbot";
changelog = "https://github.com/pgrundev/pgbot/releases/tag/v${finalAttrs.version}";
license = lib.licenses.asl20;
mainProgram = "pgbot";
};
})
4 changes: 3 additions & 1 deletion scripts/gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

# (2) Build and test from HEAD, isolated from the working tree.
git clone --quiet --local . "$tmp"
# --no-hardlinks: TMPDIR is often tmpfs (e.g. under `nix develop`) and
# hardlinking the clone fails across filesystems.
git clone --quiet --local --no-hardlinks . "$tmp"
pushd "$tmp" >/dev/null
echo "→ gating HEAD ($head) in an isolated clone"
CGO_ENABLED=0 go build ./...
Expand Down
Loading