Skip to content

feat: enable nixosTest on aarch64 darwin#1989

Merged
yvan-sraka merged 7 commits intodevelopfrom
fix/darwin-vm-tests
Feb 4, 2026
Merged

feat: enable nixosTest on aarch64 darwin#1989
yvan-sraka merged 7 commits intodevelopfrom
fix/darwin-vm-tests

Conversation

@jfroche
Copy link
Collaborator

@jfroche jfroche commented Dec 22, 2025

Build nixosTest using a local aarch64 linux builder and run nixosTest qemu VM in
aarch64 darwin. This keeps the tests fast as they don't require nested virtualisation.

For example, you can run the nixos test for the http extension on your aarch64 macOS with:

nix build .\#checks.aarch64-darwin.ext-http

Summary by CodeRabbit

  • Refactor

    • Standardized Linux-specific package resolution and host-platform inheritance across test modules and packaging paths.
  • Tests

    • Unified test harness to a Linux-focused runner, removed host→guest port forwarding and hostPkgs, added /lib to runtime links, improved service ordering/synchronization, and streamlined package wiring.
    • Added HTTP mock server integration with lifecycle and port propagation.
  • New Features

    • Added an end-to-end PostGIS multi-version upgrade test.
  • Bug Fixes

    • Improved mock-server port-file directory handling, logging, and error propagation.

@jfroche jfroche requested review from a team as code owners December 22, 2025 16:20
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

📝 Walkthrough

Walkthrough

The diff updates many Nix extension test modules and related Nix files to use Linux-specific package sets and builders (e.g., pkgs.stdenv.hostPlatform.systempkgs.pkgsLinux.stdenv.hostPlatform.system; pkgs.buildEnvpkgs.pkgsLinux.buildEnv; pkgs.makeWrapperpkgs.pkgsLinux.makeWrapper), switches test invocation sites from inputs.nixpkgs.lib.nixos.runTest to pkgs.testers.runNixOSTest, removes hostPkgs and host port‑forwarding virtualisation blocks, changes some system argument styles to inherit (stdenv.hostPlatform) system, embeds an HTTP mock-server service and port handling in the http test, hardens port-file writes in the mock server script, and adds a new multi-version PostGIS NixOS test module.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

nix, tests, extensions

Suggested reviewers

  • samrose
  • hunleyd
  • LGUG2Z
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description is incomplete. While it explains the purpose and provides usage examples, it does not follow the repository's template structure with multiple sub-templates (Default or Extension Upgrade). Select and follow the appropriate sub-template (Default or Extension Upgrade) to provide structured information about the changes, motivation, and testing approach.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling nixosTest support on aarch64 darwin by building with a local aarch64 linux builder.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/darwin-vm-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jfroche jfroche force-pushed the fix/darwin-vm-tests branch from 6dba03c to 307aa73 Compare December 22, 2025 16:29
@jfroche jfroche requested a review from a team as a code owner January 5, 2026 17:25
jfroche added a commit that referenced this pull request Jan 8, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
jfroche added a commit that referenced this pull request Jan 8, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
jfroche added a commit that referenced this pull request Jan 8, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
jfroche added a commit that referenced this pull request Jan 9, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
Base automatically changed from update-nixpkgs to develop January 16, 2026 00:23
jfroche added a commit that referenced this pull request Jan 16, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
@jfroche jfroche force-pushed the fix/darwin-vm-tests branch from fdd545e to 6953768 Compare January 16, 2026 19:48
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
nix/ext/tests/pg_plan_filter.nix (1)

62-66: Change installedExtension version to match PostgreSQL 17 in line 65.

Line 65 uses (installedExtension "15").defaultSettings for the PostgreSQL 17 configuration, but should use "17" to match the version being configured. This is inconsistent with correct patterns in pgjwt.nix line 87 and default.nix line 94, which both use (installedExtension "17").defaultSettings for their postgresql17 specialisations.

nix/ext/tests/http.nix (2)

5-9: Inconsistent host platform reference will break Darwin builds.

installedExtension uses pkgs.stdenv.hostPlatform.system while other parts of this file (lines 15, 30, 62, 79, 82) use pkgs.pkgsLinux.stdenv.hostPlatform.system. On Darwin, this resolves to aarch64-darwin vs aarch64-linux, causing a mismatch where the extension lookup targets Darwin packages but the build environment is Linux.

Other test files in this PR (e.g., pg_repack.nix, plpgsql_check.nix, pgmq.nix) consistently use pkgs.pkgsLinux for this lookup.

Proposed fix
   installedExtension =
     postgresMajorVersion:
-    self.legacyPackages.${pkgs.stdenv.hostPlatform.system}."psql_${postgresMajorVersion}".exts."${
+    self.legacyPackages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}."psql_${postgresMajorVersion}".exts."${
       pname
     }";

54-57: Inconsistent host platform reference for PostgreSQL 15.

Line 56 uses pkgs.stdenv.hostPlatform.system while the PostgreSQL 17 reference at line 62 uses pkgs.pkgsLinux.stdenv.hostPlatform.system. This inconsistency will cause version mismatch issues on Darwin hosts.

Proposed fix
       services.postgresql = {
         enable = true;
-        package = postgresqlWithExtension self.packages.${pkgs.stdenv.hostPlatform.system}.postgresql_15;
+        package = postgresqlWithExtension self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_15;
       };
nix/ext/tests/default.nix (1)

13-38: Align installedExtension to the Linux package set to avoid platform mismatch.

psql_15 and psql_17 resolve packages from pkgs.pkgsLinux.stdenv.hostPlatform.system, but installedExtension uses pkgs.stdenv.hostPlatform.system. On aarch64‑darwin, this resolves to the Darwin platform while the extensions are then mixed into a Linux buildEnv (line 23), causing cross-platform package incompatibilities. Change line 15 to use pkgs.pkgsLinux.stdenv.hostPlatform.system to keep all lookups within the same package set.

🧩 Proposed fix
-      self.legacyPackages.${pkgs.stdenv.hostPlatform.system}."psql_${postgresMajorVersion}".exts."${
+      self.legacyPackages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}."psql_${postgresMajorVersion}".exts."${
         pname
       }";
🤖 Fix all issues with AI agents
In `@nix/ext/tests/pgroonga.nix`:
- Around line 80-85: MECAB_CONFIG is set to the host-platform package pkgs.mecab
which can inject a Darwin binary into the Linux systemd service; change the
assignment to use the Linux-target package like the other vars (MECAB_DICDIR and
GRN_PLUGINS_DIR) by replacing pkgs.mecab with pkgs.pkgsLinux.mecab so
MECAB_CONFIG references the Linux mecab binary; update the
environment.MECAB_CONFIG definition to use pkgs.pkgsLinux.mecab/bin/mecab-config
to match the pattern used for GRN_PLUGINS_DIR and the mecab dictionary path.
🧹 Nitpick comments (1)
nix/ext/tests/plv8.nix (1)

58-62: Consider using the predefined psql_15 variable.

The psql_15 variable is already defined at lines 45-47 with the same expression. Other test files (e.g., pg_plan_filter.nix line 58) use the predefined variable directly:

package = psql_15;

This would reduce redundancy and align with the PR objective of removing redundant postgresqlWithExtension wrappers.

♻️ Suggested change
       services.postgresql = {
         enable = true;
-        package =
-          postgresqlWithExtension
-            self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_15;
+        package = psql_15;
         authentication = ''

jfroche added a commit that referenced this pull request Jan 26, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
@yvan-sraka yvan-sraka self-assigned this Jan 28, 2026
@yvan-sraka yvan-sraka enabled auto-merge January 28, 2026 16:42
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
nix/ext/tests/default.nix (3)

35-36: Inconsistent platform reference for OrioleDB extension.

Line 36 uses pkgs.stdenv.hostPlatform.system while the rest of the file consistently uses pkgs.pkgsLinux.stdenv.hostPlatform.system. On Darwin hosts, this would resolve to aarch64-darwin instead of aarch64-linux, likely causing the OrioleDB extension lookup to fail.

Compare with pgrouting.nix line 25 which correctly uses pkgs.pkgsLinux.stdenv.hostPlatform.system for the same OrioleDB reference.

🐛 Proposed fix
             ++ lib.optional (postgresql.isOrioleDB
-            ) self.legacyPackages.${pkgs.stdenv.hostPlatform.system}.psql_orioledb-17.exts.orioledb;
+            ) self.legacyPackages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.psql_orioledb-17.exts.orioledb;

147-151: Inconsistent platform reference in orioledb17 specialisation.

Same pattern issue: should use pkgs.pkgsLinux.stdenv.hostPlatform.system.

🐛 Proposed fix
           specialisation.orioledb17.configuration = {
             services.postgresql = {
               package = lib.mkForce (
-                postgresqlWithExtension self.packages.${pkgs.stdenv.hostPlatform.system}.postgresql_orioledb-17
+                postgresqlWithExtension self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_orioledb-17
               );

184-189: Inconsistent platform reference in orioledb17 migration script.

Same pattern issue: should use pkgs.pkgsLinux.stdenv.hostPlatform.system.

🐛 Proposed fix
               script =
                 let
                   newPostgresql =
                     postgresqlWithExtension
-                      self.packages.${pkgs.stdenv.hostPlatform.system}.postgresql_orioledb-17;
+                      self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_orioledb-17;
                 in
nix/ext/tests/http.nix (1)

23-25: Replace all pkgs.stdenv.hostPlatform.system with pkgs.pkgsLinux.stdenv.hostPlatform.system for consistency.

The file mixes pkgs.stdenv.hostPlatform.system with pkgs.pkgsLinux, which can resolve to Darwin packages when run on aarch64-darwin hosts. Since this is a Linux NixOS test, all package references must use pkgs.pkgsLinux to ensure only Linux packages are selected. This pattern is already established elsewhere in the file (line 7, 16, 33, 66) and consistently used in other test files (vault.nix, timescaledb.nix, postgis.nix, plv8.nix).

Fix locations
  • Line 24: self.legacyPackages.${pkgs.stdenv.hostPlatform.system}self.legacyPackages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}
  • Lines 47–48: self.packages.${pkgs.stdenv.hostPlatform.system}self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}
  • Line 51: self.packages.${pkgs.stdenv.hostPlatform.system}self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}
  • Line 147: self.packages.${pkgs.stdenv.hostPlatform.system}self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}
  • Line 189: self.packages.${pkgs.stdenv.hostPlatform.system}self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}
🤖 Fix all issues with AI agents
In `@nix/ext/tests/default.nix`:
- Around line 65-67: The orioledb_17 package definition uses an inconsistent
platform reference: change the platform expression used in the call to
postgresqlWithExtension for the symbol orioledb_17 from
pkgs.stdenv.hostPlatform.system to match psql_15/psql_17 by using
pkgs.pkgsLinux.stdenv.hostPlatform.system; update the RHS of orioledb_17 so it
references the same pkgs.pkgsLinux path as the other psql_* entries to restore
consistency.

In `@nix/ext/tests/postgis.nix`:
- Around line 139-156: The tests currently only assert the major version by
computing majMinVersion and checking f"{pname},{majMinVersion}" in
installed_extensions; update both checks (the first block using versions["15"]
and the upgrade block using versions["17"]) to compare the full latestVersion
string instead of slicing it—use latestVersion directly in the assertion (e.g.,
assert f"{pname},{latestVersion}" in installed_extensions) and remove the
majMinVersion computation so the test verifies the exact full extension version
installed; refer to variables latestVersion, versions, pname, and
installed_extensions to locate the changes.

Build nixosTest using a local aarch64 linux builder and run nixosTest qemu VM in
aarch64 darwin. This keeps the tests fast as they don't require nested virtualisation.

For example, you can run the nixos test for the http extension on your aarch64 macOS with:

```shell
nix build .\#checks.aarch64-darwin.ext-http
```
Current system value has been moved into `pkgs.stdenv.hostPlatform` by NixOS/nixpkgs#456527
The tests were unnecessarily wrapping psql_15 with postgresqlWithExtension when psql_15 already includes the extensions.
This cause problem starting nixos tests on darwin hosts.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
nix/ext/tests/pg_plan_filter.nix (1)

62-66: ⚠️ Potential issue | 🟡 Minor

Settings reference wrong PostgreSQL version.

In the postgresql17 specialisation, the settings still reference the PostgreSQL 15 extension defaults:

specialisation.postgresql17.configuration = {
  services.postgresql = {
    package = lib.mkForce psql_17;
    settings = (installedExtension "15").defaultSettings or { };  # Should be "17"
  };

This should likely be (installedExtension "17").defaultSettings or { } to use the correct settings for PostgreSQL 17.

Proposed fix
       specialisation.postgresql17.configuration = {
         services.postgresql = {
           package = lib.mkForce psql_17;
-          settings = (installedExtension "15").defaultSettings or { };
+          settings = (installedExtension "17").defaultSettings or { };
         };
nix/ext/tests/http.nix (1)

92-100: ⚠️ Potential issue | 🟡 Minor

Potential inconsistency: pkgs.python3 may need pkgs.pkgsLinux.python3.

The http-mock-server systemd service runs inside the Linux VM, but pkgs.python3 references the host platform's Python. For consistency with the cross-platform approach in this PR, this should likely use pkgs.pkgsLinux.python3.

🐛 Proposed fix
       systemd.services.http-mock-server = {
         wantedBy = [ "multi-user.target" ];
         serviceConfig = {
           Type = "simple";
         };
         script = ''
-          ${pkgs.python3}/bin/python3 ${../../tests/http-mock-server.py}
+          ${pkgs.pkgsLinux.python3}/bin/python3 ${../../tests/http-mock-server.py}
         '';
       };
nix/ext/tests/vault.nix (1)

46-50: ⚠️ Potential issue | 🟡 Minor

Use Linux-specific writeShellScriptBin for vaultGetKey.

vaultGetKey runs inside the Linux VM; switch to pkgs.pkgsLinux.writeShellScriptBin to ensure the script’s interpreter path exists in the VM.

Proposed fix
   vaultGetKey = lib.getExe (
-    pkgs.writeShellScriptBin "vault-getkey" ''
+    pkgs.pkgsLinux.writeShellScriptBin "vault-getkey" ''
       echo 0000000000000000000000000000000000000000000000000000000000000000
     ''
   );
🤖 Fix all issues with AI agents
In `@nix/ext/tests/index_advisor.nix`:
- Line 170: The package lookup for postgresql_orioledb-17 is inconsistent: one
usage references
self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_orioledb-17
while another uses self.packages.${pkgs.system}.postgresql_orioledb-17 (in the
expression assigned to package via lib.mkForce and postgresqlWithExtension);
make them consistent by choosing the correct platform key and updating the other
occurrence to match (either replace ${pkgs.system} with
${pkgs.pkgsLinux.stdenv.hostPlatform.system} in the
lib.mkForce/postgresqlWithExtension line, or vice versa), ensuring both
references use the same symbol so the same package path is resolved.
🧹 Nitpick comments (3)
nix/ext/tests/pgsodium.nix (1)

46-50: Consider using pkgs.pkgsLinux.writeShellScriptBin for the key script.

The pgsodiumGetKey script is used inside the NixOS VM (Linux), but it's constructed using pkgs.writeShellScriptBin from the host package set rather than pkgs.pkgsLinux.writeShellScriptBin.

Since this script runs inside the Linux VM, it may be more consistent to use the Linux-specific builder. However, since writeShellScriptBin produces a simple shell script with standard POSIX syntax, it should work regardless.

Optional consistency fix
   pgsodiumGetKey = lib.getExe (
-    pkgs.writeShellScriptBin "pgsodium-getkey" ''
+    pkgs.pkgsLinux.writeShellScriptBin "pgsodium-getkey" ''
       echo 0000000000000000000000000000000000000000000000000000000000000000
     ''
   );
nix/ext/tests/pgrouting.nix (1)

154-158: Debug commands left in migration script.

Lines 155-156 contain debugging commands that may have been used during development:

set -x
systemctl cat postgresql.service

While these won't break functionality, they add noise to test output. Consider removing them if they're no longer needed for troubleshooting.

Remove debug commands
             ''
-              set -x
-              systemctl cat postgresql.service
               rm -rf ${builtins.dirOf config.services.postgresql.dataDir}/${newPostgresql.psqlSchema}
             '';
nix/ext/tests/vault.nix (1)

74-76: Same consideration for pkgs.writeText.

The initialScript is executed inside the Linux VM. While writeText is typically architecture-agnostic (it's just text), for consistency you might consider using pkgs.pkgsLinux.writeText.

♻️ Optional consistency fix
-        initialScript = pkgs.writeText "vault-init.sql" ''
+        initialScript = pkgs.pkgsLinux.writeText "vault-init.sql" ''
           CREATE SCHEMA vault;
         '';

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nix/ext/tests/http.nix (1)

92-99: ⚠️ Potential issue | 🟠 Major

Use a Linux Python binary for the VM service.

The http-mock-server runs inside a NixOS VM; ${pkgs.python3} will resolve to a host binary (darwin on aarch64-darwin hosts) and fail at runtime. Use pkgs.pkgsLinux.python3 to ensure the VM executes the correct Linux binary, consistent with other VM packages in this file.

🛠️ Proposed fix
-          ${pkgs.python3}/bin/python3 ${../../tests/http-mock-server.py}
+          ${pkgs.pkgsLinux.python3}/bin/python3 ${../../tests/http-mock-server.py}
🧹 Nitpick comments (1)
nix/ext/tests/default.nix (1)

170-170: Optional: Consider pkgs.pkgsLinux.writeText for strict consistency.

While pkgs.writeText works correctly here (the output is a platform-independent text file), using pkgs.pkgsLinux.writeText would maintain strict consistency with the other Linux-specific derivations in this file.

This is purely cosmetic since writeText outputs are identical regardless of the builder platform.

♻️ Optional consistency fix
-            initialScript = pkgs.writeText "init-postgres-with-orioledb" ''
+            initialScript = pkgs.pkgsLinux.writeText "init-postgres-with-orioledb" ''
               CREATE EXTENSION orioledb CASCADE;
             '';

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@nix/ext/tests/http.nix`:
- Around line 91-107: The HTTP mock systemd service uses a non-Linux-specific
package reference; update the python invocation in the script for
systemd.services.http-mock-server to use the Linux package set by replacing
pkgs.python3 with pkgs.pkgsLinux.python3 so the VM uses the Linux-specific
python binary (leave environment HTTP_MOCK_PORT_FILE and the rest of the
serviceConfig unchanged).
🧹 Nitpick comments (3)
nix/ext/tests/http.nix (1)

252-260: Redundant CREATE TABLE statement.

The test_config table is already created in the initialScript (line 87). This CREATE TABLE IF NOT EXISTS is unnecessary but harmless.

Consider removing the redundant DDL:

✨ Proposed simplification
       # Read the HTTP mock port and configure it in PostgreSQL
       http_port = server.succeed("cat /tmp/http-mock-port").strip()
       server.succeed(f"""
         sudo -u postgres psql -d postgres -c '
-          CREATE TABLE IF NOT EXISTS test_config (key TEXT PRIMARY KEY, value TEXT);
           INSERT INTO test_config (key, value) VALUES ('"'"'http_mock_port'"'"', '"'"'{http_port}'"'"')
           ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value;
         '
       """)
nix/ext/tests/default.nix (1)

147-204: Consider reusing the orioledb_17 variable.

Lines 150-152 and 189 both inline the same postgresqlWithExtension call that the orioledb_17 variable (lines 65-67) already represents. This duplication could be simplified:

♻️ Proposed refactor to reuse orioledb_17
         specialisation.orioledb17.configuration = {
           services.postgresql = {
-            package = lib.mkForce (
-              postgresqlWithExtension
-                self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_orioledb-17
-            );
+            package = lib.mkForce orioledb_17;
             script =
               let
-                newPostgresql =
-                  postgresqlWithExtension
-                    self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_orioledb-17;
+                newPostgresql = orioledb_17;
               in
nix/ext/tests/index_advisor.nix (1)

129-132: Reuse orioledb_17 to remove duplicate derivation construction.
You already define orioledb_17 in the let‑bindings; reusing it here keeps the orioledb path single‑sourced and reduces evaluation duplication.

♻️ Suggested refactor
-          package = lib.mkForce (
-            postgresqlWithExtension
-              self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_orioledb-17
-          );
+          package = lib.mkForce orioledb_17;
...
-              newPostgresql =
-                postgresqlWithExtension
-                  self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_orioledb-17;
+              newPostgresql = orioledb_17;

Also applies to: 167-169

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@nix/ext/tests/http.nix`:
- Around line 249-255: The test reads /tmp/http-mock-port immediately after
waiting for units, which can race because the service is marked active before it
writes the file; before calling server.succeed("cat /tmp/http-mock-port") add an
explicit wait for the file (e.g. call a helper like
server.wait_for_path("/tmp/http-mock-port") or implement a short retry loop
using server.succeed("test -f /tmp/http-mock-port") with a timeout) so the file
exists before reading; keep existing server.wait_for_unit(...) and
server.succeed(...) calls intact and only add the file-existence wait between
them and the cat invocation.

@yvan-sraka yvan-sraka force-pushed the fix/darwin-vm-tests branch 3 times, most recently from 81565f6 to 615d3e7 Compare February 3, 2026 20:46
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@nix/tests/http-mock-server.py`:
- Around line 240-247: When writing the port file, avoid calling os.makedirs on
an empty dirname and preserve the original traceback on exceptions: compute
dirname = os.path.dirname(port_file) and only call os.makedirs(dirname,
exist_ok=True) if dirname is non-empty (or truthy), then write the file as
before; in the exception handler replace "raise e" with a bare "raise" so the
original traceback is preserved. Ensure you update the block around the
port_file write (the variables/functions referenced are port_file,
os.path.dirname, os.makedirs) accordingly.

- self.legacyPackages.${pkgs.stdenv.hostPlatform.system} -> pkgs.pkgsLinux.stdenv.hostPlatform.system
- self.packages.${pkgs.stdenv.hostPlatform.system} -> pkgs.pkgsLinux.stdenv.hostPlatform.system
- Guard against empty dirname when creating port file directory
- Use bare 'raise' to preserve original exception traceback
- Only create directory if dirname is non-empty
Changes the version assertion to compare the complete version string
rather than only the major version, providing more precise validation.
@yvan-sraka yvan-sraka added this pull request to the merge queue Feb 4, 2026
Merged via the queue into develop with commit 7de5141 Feb 4, 2026
86 checks passed
@yvan-sraka yvan-sraka deleted the fix/darwin-vm-tests branch February 4, 2026 00:43
@steve-chavez
Copy link
Member

Build nixosTest using a local aarch64 linux builder and run nixosTest qemu VM in aarch64 darwin.

I wonder if anyone can explain how is the above accomplished? Like where the qemu VM is spawned on this PR? I don't see code related to that.

jfroche added a commit that referenced this pull request Feb 5, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
jfroche added a commit that referenced this pull request Feb 5, 2026
Running NixOS tests on macOS requires a Linux VM capable of building
NixOS VMs. This adds a nix-darwin configuration that provisions an
ephemeral QEMU linux-builder with support for aarch64-linux and
x86_64-linux builds.

Usage:

    nix run github:supabase/postgres#setup-darwin-linux-builder

Enables running NixOS integration tests from macOS development machines
(see #1989).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants