From 1acc701fdbcefba6ff1aea833001b6301ad8673e Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 17 Jul 2019 17:00:46 -0400 Subject: [PATCH] nixos/binfmt: handle wasm binaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds handling for WASM binaries to binfmt’s emulatedSystems. To enable, add this to your configuration: boot.binfmt.emulatedSystems = [ "wasm32-wasi" ]; After rebuilding with nixos-rebuild switch, you can run wasm binaries directly. --- nixos/modules/system/boot/binfmt.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nixos/modules/system/boot/binfmt.nix b/nixos/modules/system/boot/binfmt.nix index d6c0f0504868..eff258945776 100644 --- a/nixos/modules/system/boot/binfmt.nix +++ b/nixos/modules/system/boot/binfmt.nix @@ -115,6 +115,14 @@ let magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00''; mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff''; }; + wasm32-wasi = { + magicOrExtension = ''\x00asm''; + mask = ''\xff\xff\xff\xff''; + }; + wasm64-wasi = { + magicOrExtension = ''\x00asm''; + mask = ''\xff\xff\xff\xff''; + }; x86_64-windows = { magicOrExtension = ".exe"; recognitionType = "extension";