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 | |
| parent | 44bf77a12ffd86294054c6e92077ea31f3613360 (diff) | |
| download | temp-postgres-b4bd5b135458660fce72b5acbbe9ed367fca4b2a.tar.gz | |
Add experimental Nix flake
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | flake.lock | 61 | ||||
| -rw-r--r-- | flake.nix | 68 | ||||
| -rw-r--r-- | version | 1 |
4 files changed, 134 insertions, 0 deletions
@@ -46,3 +46,7 @@ On Arch Linux you can install the dependencies using `pacman(8)`: $ make $ sudo make install +Alternatively you can run (or install) the experimental Nix flake. + + $ nix run git+https://git.skreutz.com/temp-postgres.git -- <dbname> <username> + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f1824cc --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1775087534, + "narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1775888245, + "narHash": "sha256-nwASzrRDD1JBEu/o8ekKYEXm/oJW6EMCzCRdrwcLe90=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "13043924aaa7375ce482ebe2494338e058282925", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1774748309, + "narHash": "sha256-+U7gF3qxzwD5TZuANzZPeJTZRHS29OFQgkQ2kiTJBIQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "333c4e0545a6da976206c74db8773a1645b5870a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} 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} + ''; + }; + }; + }; +} @@ -0,0 +1 @@ +0.2.0 |