From 629b4ee093941ee8338a68b3f018e27a2e415b33 Mon Sep 17 00:00:00 2001 From: Sam Pointon Date: Mon, 15 Jun 2026 12:35:25 +0100 Subject: [PATCH] systems: rename extant wasi targets to wasip1 Wasi P2 is different enough to Wasi P1 to warrant being treated entirely separately, rather than as two minor variants of the same thing. P3 will likewise want to be a different target. I've left aliases in place; maybe eventually, those can be deprecated and removed. I've tested this, but it's possible there might be breakage somewhere (e.g., the canonical doubles for P1 have changed, though I can't imagine why anyone would rely on that). Fixes https://github.com/NixOS/nixpkgs/issues/435954 --- lib/systems/default.nix | 12 +++++------- lib/systems/doubles.nix | 4 ++-- lib/systems/examples.nix | 3 ++- lib/systems/inspect.nix | 7 +++++-- lib/systems/parse.nix | 3 ++- nixos/lib/binfmt-magics.nix | 4 ++-- nixos/modules/system/boot/binfmt.nix | 2 +- nixos/tests/systemd-binfmt.nix | 2 +- pkgs/build-support/build-mozilla-mach/default.nix | 4 ++-- pkgs/by-name/ex/extism-js-core/package.nix | 8 +++++--- pkgs/development/compilers/rust/binary.nix | 2 +- 11 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 05da6815ceba..273c07a0a8f9 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -245,7 +245,7 @@ let netbsd = "NetBSD"; freebsd = "FreeBSD"; openbsd = "OpenBSD"; - wasi = "Wasi"; + wasip1 = "WasiP1"; redox = "Redox"; genode = "Genode"; } @@ -470,6 +470,8 @@ let rust.platform.os or "none" else if final.isDarwin then "macos" + else if final.isWasi then + "wasi" else if final.isWasm && !final.isWasi then "unknown" # Needed for {wasm32,wasm64}-unknown-unknown. else @@ -528,11 +530,7 @@ let abi.name; inferred = - if final.isWasi then - # Rust uses `wasm32-wasip?` rather than `wasm32-unknown-wasi`. - # We cannot know which subversion does the user want, and - # currently use WASI 0.1 as default for compatibility. Custom - # users can set `rust.rustcTargetSpec` to override it. + if final.isWasiP1 then "${cpu_}-wasip1" else "${cpu_}-${vendor_}-${kernel.name}${optionalString (abi.name != "unknown") "-${abi_}"}"; @@ -595,7 +593,7 @@ let "wasm32" = "wasm"; } .${final.parsed.cpu.name} or null; - GOOS = if final.isWasi then "wasip1" else final.parsed.kernel.name; + GOOS = if final.isWasiP1 then "wasip1" else final.parsed.kernel.name; # See https://go.dev/wiki/GoArm GOARM = toString (lib.intersectLists [ (final.parsed.cpu.version or "") ] [ "5" "6" "7" ]); diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index 3970b69735a9..5b3bf2630b6d 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -112,8 +112,8 @@ let "x86_64-redox" # WASI - "wasm64-wasi" - "wasm32-wasi" + "wasm64-wasip1" + "wasm32-wasip1" # Windows "aarch64-windows" diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index ab062f82bce3..1a88d1605ebc 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -443,8 +443,9 @@ rec { # WASM # + # For historical reasons, Nixpkgs's wasi32 (i.e., without a revision number) corresponds to WASI p1. wasi32 = { - config = "wasm32-unknown-wasi"; + config = "wasm32-unknown-wasip1"; useLLVM = true; }; diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 9ef67e0ec2cf..627d7e1ad38c 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -392,8 +392,11 @@ rec { kernel = kernels.windows; abi = abis.msvc; }; - isWasi = { - kernel = kernels.wasi; + isWasi = [ + { kernel = kernels.wasip1; } + ]; + isWasiP1 = { + kernel = kernels.wasip1; }; isRedox = { kernel = kernels.redox; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index cdfeafe7c18d..1cd608d7c760 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -601,7 +601,7 @@ rec { execFormat = elf; families = { }; }; - wasi = { + wasip1 = { execFormat = wasm; families = { }; }; @@ -640,6 +640,7 @@ rec { darwin = kernels.macos; watchos = kernels.ios; tvos = kernels.ios; + wasi = kernels.wasip1; win32 = kernels.windows; }; diff --git a/nixos/lib/binfmt-magics.nix b/nixos/lib/binfmt-magics.nix index 0d8ae95d73d1..2859f9ff1b19 100644 --- a/nixos/lib/binfmt-magics.nix +++ b/nixos/lib/binfmt-magics.nix @@ -95,11 +95,11 @@ magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01''; mask = ''\xff\xff\xff\xff\xff\xff\xff\xfc\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff''; }; - wasm32-wasi = { + wasm32-wasip1 = { magicOrExtension = ''\x00asm''; mask = ''\xff\xff\xff\xff''; }; - wasm64-wasi = { + wasm64-wasip1 = { magicOrExtension = ''\x00asm''; mask = ''\xff\xff\xff\xff''; }; diff --git a/nixos/modules/system/boot/binfmt.nix b/nixos/modules/system/boot/binfmt.nix index c31245352846..5506dc16bdc4 100644 --- a/nixos/modules/system/boot/binfmt.nix +++ b/nixos/modules/system/boot/binfmt.nix @@ -189,7 +189,7 @@ in emulatedSystems = mkOption { default = [ ]; example = [ - "wasm32-wasi" + "wasm32-wasip1" "x86_64-windows" "aarch64-linux" ]; diff --git a/nixos/tests/systemd-binfmt.nix b/nixos/tests/systemd-binfmt.nix index bab073954a9a..c062acbde10d 100644 --- a/nixos/tests/systemd-binfmt.nix +++ b/nixos/tests/systemd-binfmt.nix @@ -112,7 +112,7 @@ in { boot.binfmt.emulatedSystems = [ "aarch64-linux" - "wasm32-wasi" + "wasm32-wasip1" ]; boot.binfmt.preferStaticEmulators = true; diff --git a/pkgs/build-support/build-mozilla-mach/default.nix b/pkgs/build-support/build-mozilla-mach/default.nix index 09eef8b2496f..277c6a83f25f 100644 --- a/pkgs/build-support/build-mozilla-mach/default.nix +++ b/pkgs/build-support/build-mozilla-mach/default.nix @@ -245,9 +245,9 @@ let # https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/ # We only link c++ libs here, our compiler wrapper can find wasi libc and crt itself. wasiSysRoot = runCommand "wasi-sysroot" { } '' - mkdir -p $out/lib/wasm32-wasi + mkdir -p $out/lib/wasm32-wasip1 for lib in ${pkgsCross.wasi32.llvmPackages.libcxx}/lib/*; do - ln -s $lib $out/lib/wasm32-wasi + ln -s $lib $out/lib/wasm32-wasip1 done ''; diff --git a/pkgs/by-name/ex/extism-js-core/package.nix b/pkgs/by-name/ex/extism-js-core/package.nix index 6b6963677b9e..1a1e72fd1011 100644 --- a/pkgs/by-name/ex/extism-js-core/package.nix +++ b/pkgs/by-name/ex/extism-js-core/package.nix @@ -67,8 +67,8 @@ rustPlatform.buildRustPackage (finalAttrs: { # TODO: revisit when https://github.com/DelSkayn/rquickjs/pull/648 is released and extism updated env.WASI_SDK = runCommand "wasi-sdk" { } '' mkdir -p $out/bin - ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasi-clang"} $out/bin/clang - ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasi-ar"} $out/bin/ar + ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasip1-clang"} $out/bin/clang + ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasip1-ar"} $out/bin/ar ln -s ${stdenv.cc}/nix-support $out/nix-support mkdir -p $out/share ln -s ${stdenv.cc.libc} $out/share/wasi-sysroot @@ -90,6 +90,8 @@ rustPlatform.buildRustPackage (finalAttrs: { lib.maintainers.diogotcorreia lib.maintainers.dotlambda ]; - platforms = lib.platforms.wasi; + platforms = [ + "wasm32-wasip1" + ]; }; }) diff --git a/pkgs/development/compilers/rust/binary.nix b/pkgs/development/compilers/rust/binary.nix index f540e775dfd9..82643f4a6f41 100644 --- a/pkgs/development/compilers/rust/binary.nix +++ b/pkgs/development/compilers/rust/binary.nix @@ -120,7 +120,7 @@ rec { "riscv64-netbsd" "riscv32-none" "x86_64-redox" - "wasm32-wasi" + "wasm32-wasip1" ]; badTargetPlatforms = [ # Rust is currently unable to target the n32 ABI