pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Add pgschema to nix package

Open JannisKoeksel opened this issue 9 months ago • 3 comments

As the title says, it would be super helpful to have it as a nix package. For our case it would be used twofold:

  1. Being used in the local env during development without having to install for each new mashine
  2. We are building our container with nix and created a little K8s operator around pgschema, which is the only tool that needs the Docker image.

JannisKoeksel avatar Feb 28 '26 11:02 JannisKoeksel

I have little experience with nix. Contribution welcome

tianzhou avatar Feb 28 '26 11:02 tianzhou

Not familiar with Go, but the Dockerfile looks simple enough. I will look into it.

JannisKoeksel avatar Feb 28 '26 12:02 JannisKoeksel

One can use:

{
  lib,
  buildGoModule,
  fetchFromGitHub,
}:

buildGoModule rec {
  pname = "pgschema";
  version = "1.7.4";

  src = fetchFromGitHub {
    owner = "pgplex";
    repo = "pgschema";
    rev = "v${version}";
    hash = "sha256-c1Z8mubchdP+dMROf2fa+H+mN/y3MuGhSY7Cs0MEAzw=";
  };

  vendorHash = "sha256-NXTGbts0Mb/h/ymL76kpFUMBZ+kNt06+KdtVsDFeGYw=";

  ldflags = [
    "-s"
    "-w"
  ];

  doCheck = false;

  meta = with lib; {
    description = "Terraform-style declarative schema migration CLI for Postgres";
    homepage = "https://www.pgschema.com";
    changelog = "https://github.com/pgplex/pgschema/releases/tag/v${version}";
    license = licenses.asl20;
    mainProgram = "pgschema";
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = [ ];
  };
}

And then use it in a nix flake via import pgschema = pkgs.callPackage <your path>/pgschema/default.nix { };

JannisKoeksel avatar Apr 23 '26 15:04 JannisKoeksel