From b364792c3328075645b498a8034e49391b8aa783 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 21 Jun 2023 15:47:09 -0400 Subject: [PATCH] Finish the example .. which was accidentally commited, partially, in parent commit. Pending a FIXME in tests. --- example/.gitignore | 1 + example/flake.lock | 129 +++++++++++++++++++++++++++++++++++++++++++++ example/flake.nix | 11 ++-- test.sh | 3 ++ 4 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 example/.gitignore create mode 100644 example/flake.lock diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..3af0ccb --- /dev/null +++ b/example/.gitignore @@ -0,0 +1 @@ +/data diff --git a/example/flake.lock b/example/flake.lock new file mode 100644 index 0000000..5bc71ed --- /dev/null +++ b/example/flake.lock @@ -0,0 +1,129 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1685662779, + "narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687274257, + "narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1685564631, + "narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "northwind": { + "flake": false, + "locked": { + "lastModified": 1666887048, + "narHash": "sha256-wwqHEkZUTNkg78OLnRDX5JPoRYop8v5UI2hxZTclxs8=", + "owner": "pthom", + "repo": "northwind_psql", + "rev": "3d271b23f3357532e63f92ffb10c4f258dfd20af", + "type": "github" + }, + "original": { + "owner": "pthom", + "repo": "northwind_psql", + "type": "github" + } + }, + "process-compose-flake": { + "locked": { + "lastModified": 1687298948, + "narHash": "sha256-7Lu4/odCkkwrzR8Mo+3D+URv4oLap8WWLESzi/75eb0=", + "owner": "Platonic-Systems", + "repo": "process-compose-flake", + "rev": "5bdb90b85642901cf9a5dccfe8c907091c261604", + "type": "github" + }, + "original": { + "owner": "Platonic-Systems", + "repo": "process-compose-flake", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "northwind": "northwind", + "process-compose-flake": "process-compose-flake", + "services-flake": "services-flake", + "systems": "systems" + } + }, + "services-flake": { + "locked": { + "lastModified": 1687358997, + "narHash": "sha256-TjBp031+x3gHM2fRPA2GITXJWTwCstIeQb04rp8Iokk=", + "owner": "juspay", + "repo": "services-flake", + "rev": "27c3221de252b393d9ddbb5cc31ba71b94477cf9", + "type": "github" + }, + "original": { + "owner": "juspay", + "repo": "services-flake", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/example/flake.nix b/example/flake.nix index f813897..65c1b92 100644 --- a/example/flake.nix +++ b/example/flake.nix @@ -28,25 +28,26 @@ enable = true; listen_addresses = "127.0.0.1"; initialDatabases = [ - { - name = "sample"; + { + name = "sample"; schema = "${inputs.northwind}/northwind.sql"; - } + } ]; }; settings.processes.pgweb = { environment.PGWEB_DATABASE_URL = "postgres://srid@127.0.0.1:5432/sample"; command = pkgs.pgweb; - depends_on."postgres".condition = "process_started"; + depends_on."postgres".condition = "process_healthy"; }; # Set this attribute and get NixOS VM tests, as a flake check, for free. testScript = '' + # FIXME: pgweb is still pending, but only in VM tests for some reason. process_compose.wait_until(lambda procs: procs["postgres"]["status"] == "Running" ) - machine.succeed("echo 'SELECT version();' | ${config.services.postgres.package}/bin/psql -h 127.0.0.1 -U tester chinook") + machine.succeed("echo 'SELECT version();' | ${config.services.postgres.package}/bin/psql -h 127.0.0.1 -U tester sample") ''; }; }; diff --git a/test.sh b/test.sh index b4e1d73..49ee207 100755 --- a/test.sh +++ b/test.sh @@ -4,6 +4,9 @@ cd "$(dirname "$0")" # On NixOS, run the VM tests to test runtime behaviour if command -v nixos-rebuild &> /dev/null; then + # example test + nix flake check -L ./example --override-input services-flake . + # service tests nix flake check -L ./test --override-input services-flake . fi