Skip to content

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

    • Updated internal build infrastructure to use Linux-specific package configurations across test environments.
    • Streamlined test harness integration by consolidating package references and removing redundant configuration layers.
  • Tests

    • Modernized test runner framework and simplified network configuration for extension validation tests.

✏️ Tip: You can customize this high-level summary in your review settings.

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

coderabbitai bot commented Dec 22, 2025

Walkthrough

This pull request systematically migrates Nix test configurations from generic package references to Linux-specific namespaces (pkgs.pkgsLinux), updates the test runner infrastructure from nixpkgs.lib.nixos.runTest to pkgs.testers.runNixOSTest, removes host port-forwarding virtualization blocks, and adjusts closure argument passing styles across multiple files.

Changes

Cohort / File(s) Summary
Nix closure argument style
nix/cargo-pgrx/mkPgrxExtension.nix, nix/postgresql/generic.nix
Changes system assignment from direct value (system = stdenv.hostPlatform.system) to inheritance syntax (inherit (stdenv.hostPlatform) system) in closure arguments; preserves functionality with updated parameter-passing convention.
Checks configuration restructuring
nix/checks.nix
Reorders structure to extract ext/tests import outside of Linux-specific conditional block; moves optional PostgreSQL checks into a separate attribute set.
Test infrastructure migration
nix/ext/tests/{default,http,orioledb,pg_plan_filter,pg_repack,pg_safeupdate,pgjwt,pgmq,pgroonga,pgrouting,pgsodium,plpgsql_check,plv8,postgis,timescaledb,vault}.nix
Systematic changes across 16 test files: replaces pkgs references with pkgs.pkgsLinux for buildEnv, makeWrapper, and stdenv operations; updates test runner from inputs.nixpkgs.lib.nixos.runTest to pkgs.testers.runNixOSTest; removes hostPkgs assignments and virtualisation.forwardPorts blocks; updates all platform-specific package lookups to use Linux namespace.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Update nixpkgs #1714: Related changes to the same Nix files involving system attribute threading and closure argument style updates across test and build configurations.

Suggested reviewers

  • samrose
  • LGUG2Z

Poem

🐰 Hippity-hops through Linux paths so green,
The pkgsLinux namespace, a cleaner scene,
From runTest to testers, the runners align,
No forward ports needed—the tests now shine,
A systematic migration, so thoughtfully done! 🌿✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature: enabling nixosTest functionality on aarch64 Darwin architecture.
Description check ✅ Passed The PR description explains the motivation, approach, and provides a concrete usage example, demonstrating how the changes improve test execution on aarch64 macOS.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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).
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.
@jfroche jfroche force-pushed the fix/darwin-vm-tests branch from fdd545e to 6953768 Compare January 16, 2026 19:48
Copy link

@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 = ''

Comment on lines +80 to 85
self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.mecab-naist-jdic
}/lib/mecab/dic/naist-jdic";
systemd.services.postgresql.environment.MECAB_CONFIG = "${pkgs.mecab}/bin/mecab-config";
systemd.services.postgresql.environment.GRN_PLUGINS_DIR = "${
self.packages.${pkgs.stdenv.hostPlatform.system}.supabase-groonga
self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.supabase-groonga
}/lib/groonga/plugins";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n nix/ext/tests/pgroonga.nix | sed -n '70,95p'

Repository: supabase/postgres

Length of output: 1181


🏁 Script executed:

rg -i "mecab|pkgsLinux" nix/ext/tests/pgroonga.nix

Repository: supabase/postgres

Length of output: 790


🏁 Script executed:

head -n 50 nix/ext/tests/pgroonga.nix

Repository: supabase/postgres

Length of output: 1627


🏁 Script executed:

cat -n nix/ext/tests/pgroonga.nix | sed -n '50,90p'

Repository: supabase/postgres

Length of output: 1584


🏁 Script executed:

rg "pkgsLinux\.mecab" --max-count 5

Repository: supabase/postgres

Length of output: 43


🌐 Web query:

nixpkgs pkgsLinux.mecab availability cross-compilation

💡 Result:

Short answer: mecab is packaged in nixpkgs (pkgs.tools.text.mecab) and is cross‑buildable — there was a recent merge to fix its cross build. Use pkgsCross..mecab or import nixpkgs with crossSystem to get a cross toolchain.

References:

  • mecab package entry in nixpkgs (attribute pkgs/tools/text/mecab). (mynixos.com)
  • PR fixing mecab cross build (merged). (app.semanticdiff.com)
  • Nix cross‑compilation docs / pkgsCross usage (examples). (nix.dev)

Example (build for aarch64-linux):

  • nix-build '' -A pkgsCross.aarch64-multiplatform.mecab
    or import with crossSystem = { config = "aarch64-unknown-linux-gnu"; } and use pkgs.mecab. (nix.dev)

If you want, tell me which nixpkgs commit/channel and target platform you plan to use and I’ll give exact commands for that revision.

Citations:


🏁 Script executed:

rg "pkgsLinux\s*=" nix/ -A 3 | head -40

Repository: supabase/postgres

Length of output: 43


🏁 Script executed:

rg "pkgsLinux" nix/ -B 2 | head -50

Repository: supabase/postgres

Length of output: 2902


🏁 Script executed:

cat -n nix/ext/tests/pgroonga.nix | sed -n '75,90p'

Repository: supabase/postgres

Length of output: 846


Fix host/guest platform mismatch for MECAB_CONFIG.

MECAB_CONFIG uses pkgs.mecab (host platform), while related environment variables (MECAB_DICDIR and GRN_PLUGINS_DIR) use pkgs.pkgsLinux packages. On aarch64-darwin, this causes the Darwin binary to be injected into the Linux systemd service. Change to pkgs.pkgsLinux.mecab for consistency.

🛠️ Proposed fix
-      systemd.services.postgresql.environment.MECAB_CONFIG = "${pkgs.mecab}/bin/mecab-config";
+      systemd.services.postgresql.environment.MECAB_CONFIG = "${pkgs.pkgsLinux.mecab}/bin/mecab-config";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.mecab-naist-jdic
}/lib/mecab/dic/naist-jdic";
systemd.services.postgresql.environment.MECAB_CONFIG = "${pkgs.mecab}/bin/mecab-config";
systemd.services.postgresql.environment.GRN_PLUGINS_DIR = "${
self.packages.${pkgs.stdenv.hostPlatform.system}.supabase-groonga
self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.supabase-groonga
}/lib/groonga/plugins";
self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.mecab-naist-jdic
}/lib/mecab/dic/naist-jdic";
systemd.services.postgresql.environment.MECAB_CONFIG = "${pkgs.pkgsLinux.mecab}/bin/mecab-config";
systemd.services.postgresql.environment.GRN_PLUGINS_DIR = "${
self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.supabase-groonga
}/lib/groonga/plugins";
🤖 Prompt for AI Agents
In `@nix/ext/tests/pgroonga.nix` around lines 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.

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.

2 participants