diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 22202de4d..632bfd4cf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -68,6 +68,11 @@ jobs: path: postgrest-docker-${{ matrix.artifact }}.tar.gz if-no-files-found: error + - name: Test static executable with NixOS' VM test + # GHA's ARM runner does not support KVM + if: runner.arch == 'X64' + run: nix-build -A nixpkgs-nixos-test + macos: name: Nix - MacOS diff --git a/default.nix b/default.nix index 859c3ebb4..2161e2624 100644 --- a/default.nix +++ b/default.nix @@ -77,6 +77,16 @@ let "-f dev --test-show-detail=direct"; inherit (pkgs.haskell) lib; + + nixos-lib = import (pkgs.path + "/nixos/lib") { }; + runTest = postgrest: test: (nixos-lib.runTest { + hostPkgs = pkgs; + # Replace the top-level `pkgs.postgrest` attribute with our current version on this branch. + defaults.nixpkgs.overlays = [ (_: _: { inherit postgrest; }) ]; + # Speeds up evaluation a little bit; documentation is really not required for tests. + defaults.documentation.enable = pkgs.lib.mkDefault false; + imports = [ test ]; + }).config.result; in rec { inherit nixpkgs pkgs; @@ -162,4 +172,7 @@ rec { # Docker images and loading script. docker = pkgs.callPackage nix/tools/docker { postgrest = postgrestStatic; }; + + # NixOS VM tests + nixpkgs-nixos-test = runTest postgrestStatic (pkgs.path + "/nixos/tests/postgrest.nix"); }