diff options
| author | Stefan Kreutz <mail@skreutz.com> | 2026-04-15 13:15:12 +0200 |
|---|---|---|
| committer | Stefan Kreutz <mail@skreutz.com> | 2026-04-15 13:15:12 +0200 |
| commit | b4bd5b135458660fce72b5acbbe9ed367fca4b2a (patch) | |
| tree | 856eb5bbe64db16622d45aec9c12e9b75de7ce93 /flake.nix | |
| parent | 44bf77a12ffd86294054c6e92077ea31f3613360 (diff) | |
| download | temp-postgres-b4bd5b135458660fce72b5acbbe9ed367fca4b2a.tar.gz | |
Add experimental Nix flake
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bedd3af --- /dev/null +++ b/flake.nix @@ -0,0 +1,68 @@ +{ + description = "Run the PostgreSQL server off a temporary data directory"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = + inputs@{ + self, + nixpkgs, + flake-parts, + ... + }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + + perSystem = + { + self', + pkgs, + lib, + ... + }: + let + version = builtins.head (lib.splitString "\n" (builtins.readFile ./version)); + revision = lib.toString (self.shortRev or self.dirtyShortRev or "unknown"); + in + { + packages.default = self'.packages.temp-postgres; + + packages.temp-postgres = pkgs.stdenv.mkDerivation { + name = "temp-postgres-${version}-${revision}"; + version = "${version}-${revision}"; + src = lib.cleanSource ( + builtins.path { + path = ./.; + name = "temp-postgres"; + } + ); + nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; + installPhase = '' + mkdir -p $out/bin + cp temp-postgres.sh $out/bin/temp-postgres + mkdir -p $out/man/man1 + cp temp-postgres.1 $out/man/man1/temp-postgres.1 + wrapProgram $out/bin/temp-postgres --prefix PATH : ${lib.makeBinPath [ pkgs.postgresql ]} + ''; + }; + + formatter = pkgs.nixfmt-tree; + + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + postgresql + ]; + shellHook = '' + export FLAKE=${self} + ''; + }; + }; + }; +} |