-
-
Notifications
You must be signed in to change notification settings - Fork 226
feat: enable nixosTest on aarch64 darwin #1989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request systematically migrates Nix test configurations from generic package references to Linux-specific namespaces ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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. Comment |
6dba03c to
307aa73
Compare
acf3ba4 to
42b0c29
Compare
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).
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).
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).
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).
fa26b67 to
0131d17
Compare
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.
fdd545e to
6953768
Compare
There was a problem hiding this 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").defaultSettingsfor the PostgreSQL 17 configuration, but should use"17"to match the version being configured. This is inconsistent with correct patterns inpgjwt.nixline 87 anddefault.nixline 94, which both use(installedExtension "17").defaultSettingsfor their postgresql17 specialisations.nix/ext/tests/http.nix (2)
5-9: Inconsistent host platform reference will break Darwin builds.
installedExtensionusespkgs.stdenv.hostPlatform.systemwhile other parts of this file (lines 15, 30, 62, 79, 82) usepkgs.pkgsLinux.stdenv.hostPlatform.system. On Darwin, this resolves toaarch64-darwinvsaarch64-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 usepkgs.pkgsLinuxfor 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.systemwhile the PostgreSQL 17 reference at line 62 usespkgs.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: AligninstalledExtensionto the Linux package set to avoid platform mismatch.
psql_15andpsql_17resolve packages frompkgs.pkgsLinux.stdenv.hostPlatform.system, butinstalledExtensionusespkgs.stdenv.hostPlatform.system. On aarch64‑darwin, this resolves to the Darwin platform while the extensions are then mixed into a LinuxbuildEnv(line 23), causing cross-platform package incompatibilities. Change line 15 to usepkgs.pkgsLinux.stdenv.hostPlatform.systemto 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 predefinedpsql_15variable.The
psql_15variable is already defined at lines 45-47 with the same expression. Other test files (e.g.,pg_plan_filter.nixline 58) use the predefined variable directly:package = psql_15;This would reduce redundancy and align with the PR objective of removing redundant
postgresqlWithExtensionwrappers.♻️ Suggested change
services.postgresql = { enable = true; - package = - postgresqlWithExtension - self.packages.${pkgs.pkgsLinux.stdenv.hostPlatform.system}.postgresql_15; + package = psql_15; authentication = ''
| 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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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.nixRepository: supabase/postgres
Length of output: 790
🏁 Script executed:
head -n 50 nix/ext/tests/pgroonga.nixRepository: 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 5Repository: 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:
- 1: https://mynixos.com/nixpkgs/package/mecab?utm_source=openai
- 2: https://app.semanticdiff.com/gh/NixOS/nixpkgs/pull/373789/overview?utm_source=openai
- 3: https://nix.dev/tutorials/cross-compilation.html?utm_source=openai
- 4: https://nix.dev/tutorials/cross-compilation.html?utm_source=openai
🏁 Script executed:
rg "pkgsLinux\s*=" nix/ -A 3 | head -40Repository: supabase/postgres
Length of output: 43
🏁 Script executed:
rg "pkgsLinux" nix/ -B 2 | head -50Repository: 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.
| 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.
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-httpSummary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.