From 1acc701fdbcefba6ff1aea833001b6301ad8673e Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 17 Jul 2019 17:00:46 -0400 Subject: 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(+) (limited to 'nixos/modules/system') 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"; -- cgit 1.4.1 From 857f7fb4af34d3417b8d1a0e901ba75f4cba39a0 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 17 Jul 2019 17:09:20 -0400 Subject: nixos/binfmt: update release notes and provide examples --- nixos/doc/manual/release-notes/rl-1909.xml | 9 +++++++++ nixos/modules/system/boot/binfmt.nix | 1 + 2 files changed, 10 insertions(+) (limited to 'nixos/modules/system') diff --git a/nixos/doc/manual/release-notes/rl-1909.xml b/nixos/doc/manual/release-notes/rl-1909.xml index 30570a279eca..dbbf46dfa832 100644 --- a/nixos/doc/manual/release-notes/rl-1909.xml +++ b/nixos/doc/manual/release-notes/rl-1909.xml @@ -33,6 +33,15 @@ PHP 7.1 is no longer supported due to upstream not supporting this version for the entire lifecycle of the 19.09 release. + + + The binfmt module is now easier to use. Additional systems can + be added through . + For instance, boot.binfmt.emulatedSystems = [ + "wasm32-wasi" "x86_64-windows" "aarch64-linux" ]; will + set up binfmt interpreters for each of those listed systems. + + diff --git a/nixos/modules/system/boot/binfmt.nix b/nixos/modules/system/boot/binfmt.nix index eff258945776..a550ffd6320f 100644 --- a/nixos/modules/system/boot/binfmt.nix +++ b/nixos/modules/system/boot/binfmt.nix @@ -234,6 +234,7 @@ in { emulatedSystems = mkOption { default = []; + example = [ "wasm32-wasi" "x86_64-windows" "aarch64-linux" ]; description = '' List of systems to emulate. Will also configure Nix to support your new systems. -- cgit 1.4.1 From 88bb9fa4037c7cda4cb2fb94792d17e44fd55a18 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 8 Aug 2019 23:35:52 +0200 Subject: nixos/modules: Replace all nested types.either's with types.oneOf's --- nixos/modules/services/backup/automysqlbackup.nix | 2 +- nixos/modules/services/games/minecraft-server.nix | 2 +- nixos/modules/services/mail/davmail.nix | 2 +- nixos/modules/services/mail/postfix.nix | 2 +- nixos/modules/services/mail/rspamd.nix | 2 +- nixos/modules/services/mail/rss2email.nix | 2 +- nixos/modules/services/networking/znc/default.nix | 4 ++-- nixos/modules/services/security/bitwarden_rs/default.nix | 2 +- nixos/modules/services/web-apps/limesurvey.nix | 2 +- nixos/modules/services/x11/compton.nix | 2 +- nixos/modules/system/boot/systemd-unit-options.nix | 2 +- nixos/modules/system/boot/systemd.nix | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) (limited to 'nixos/modules/system') diff --git a/nixos/modules/services/backup/automysqlbackup.nix b/nixos/modules/services/backup/automysqlbackup.nix index b845f370fb70..1884f3536a97 100644 --- a/nixos/modules/services/backup/automysqlbackup.nix +++ b/nixos/modules/services/backup/automysqlbackup.nix @@ -41,7 +41,7 @@ in }; config = mkOption { - type = with types; attrsOf (either (either str (either int bool)) (listOf str)); + type = with types; attrsOf (oneOf [ str int bool (listOf str) ]); default = {}; description = '' automysqlbackup configuration. Refer to diff --git a/nixos/modules/services/games/minecraft-server.nix b/nixos/modules/services/games/minecraft-server.nix index 39a68f4b5536..eb9288fca586 100644 --- a/nixos/modules/services/games/minecraft-server.nix +++ b/nixos/modules/services/games/minecraft-server.nix @@ -118,7 +118,7 @@ in { }; serverProperties = mkOption { - type = with types; attrsOf (either bool (either int str)); + type = with types; attrsOf (oneOf [ bool int str ]); default = {}; example = literalExample '' { diff --git a/nixos/modules/services/mail/davmail.nix b/nixos/modules/services/mail/davmail.nix index 5b5cc294e5c7..374a3dd75c1c 100644 --- a/nixos/modules/services/mail/davmail.nix +++ b/nixos/modules/services/mail/davmail.nix @@ -7,7 +7,7 @@ let cfg = config.services.davmail; configType = with types; - either (either (attrsOf configType) str) (either int bool) // { + oneOf [ (attrsOf configType) str int bool ] // { description = "davmail config type (str, int, bool or attribute set thereof)"; }; diff --git a/nixos/modules/services/mail/postfix.nix b/nixos/modules/services/mail/postfix.nix index dab1b29aa4be..2b08ab1e6aa6 100644 --- a/nixos/modules/services/mail/postfix.nix +++ b/nixos/modules/services/mail/postfix.nix @@ -447,7 +447,7 @@ in }; config = mkOption { - type = with types; attrsOf (either bool (either str (listOf str))); + type = with types; attrsOf (oneOf [ bool str (listOf str) ]); description = '' The main.cf configuration file as key value set. ''; diff --git a/nixos/modules/services/mail/rspamd.nix b/nixos/modules/services/mail/rspamd.nix index 5541b8b79b7e..e59d5715de05 100644 --- a/nixos/modules/services/mail/rspamd.nix +++ b/nixos/modules/services/mail/rspamd.nix @@ -331,7 +331,7 @@ in }; config = mkOption { - type = with types; attrsOf (either bool (either str (listOf str))); + type = with types; attrsOf (oneOf [ bool str (listOf str) ]); description = '' Addon to postfix configuration ''; diff --git a/nixos/modules/services/mail/rss2email.nix b/nixos/modules/services/mail/rss2email.nix index a123736005ab..df454abc8267 100644 --- a/nixos/modules/services/mail/rss2email.nix +++ b/nixos/modules/services/mail/rss2email.nix @@ -30,7 +30,7 @@ in { }; config = mkOption { - type = with types; attrsOf (either str (either int bool)); + type = with types; attrsOf (oneOf [ str int bool ]); default = {}; description = '' The configuration to give rss2email. diff --git a/nixos/modules/services/networking/znc/default.nix b/nixos/modules/services/networking/znc/default.nix index 46bff6954cdd..05f97bfa539f 100644 --- a/nixos/modules/services/networking/znc/default.nix +++ b/nixos/modules/services/networking/znc/default.nix @@ -62,9 +62,9 @@ let concatStringsSep "\n" (toLines cfg.config); semanticTypes = with types; rec { - zncAtom = nullOr (either (either int bool) str); + zncAtom = nullOr (oneOf [ int bool str ]); zncAttr = attrsOf (nullOr zncConf); - zncAll = either (either zncAtom (listOf zncAtom)) zncAttr; + zncAll = oneOf [ zncAtom (listOf zncAtom) zncAttr ]; zncConf = attrsOf (zncAll // { # Since this is a recursive type and the description by default contains # the description of its subtypes, infinite recursion would occur without diff --git a/nixos/modules/services/security/bitwarden_rs/default.nix b/nixos/modules/services/security/bitwarden_rs/default.nix index bb036ee020f4..80fd65891ff8 100644 --- a/nixos/modules/services/security/bitwarden_rs/default.nix +++ b/nixos/modules/services/security/bitwarden_rs/default.nix @@ -36,7 +36,7 @@ in { }; config = mkOption { - type = attrsOf (nullOr (either (either bool int) str)); + type = attrsOf (nullOr (oneOf [ bool int str ])); default = {}; example = literalExample '' { diff --git a/nixos/modules/services/web-apps/limesurvey.nix b/nixos/modules/services/web-apps/limesurvey.nix index 5b2f3875aaa9..84a94fc446e5 100644 --- a/nixos/modules/services/web-apps/limesurvey.nix +++ b/nixos/modules/services/web-apps/limesurvey.nix @@ -14,7 +14,7 @@ let pkg = pkgs.limesurvey; - configType = with types; either (either (attrsOf configType) str) (either int bool) // { + configType = with types; oneOf [ (attrsOf configType) str int bool ] // { description = "limesurvey config type (str, int, bool or attribute set thereof)"; }; diff --git a/nixos/modules/services/x11/compton.nix b/nixos/modules/services/x11/compton.nix index c02c9bfd94e8..a94a76ff0c0f 100644 --- a/nixos/modules/services/x11/compton.nix +++ b/nixos/modules/services/x11/compton.nix @@ -215,7 +215,7 @@ in { }; settings = let - configTypes = with types; either bool (either int (either float str)); + configTypes = with types; oneOf [ bool int float str ]; # types.loaOf converts lists to sets loaOf = t: with types; either (listOf t) (attrsOf t); in mkOption { diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix index ee4ae845a7d5..c1f2c98afcd8 100644 --- a/nixos/modules/system/boot/systemd-unit-options.nix +++ b/nixos/modules/system/boot/systemd-unit-options.nix @@ -226,7 +226,7 @@ in rec { environment = mkOption { default = {}; - type = with types; attrsOf (nullOr (either str (either path package))); + type = with types; attrsOf (nullOr (oneOf [ str path package ])); example = { PATH = "/foo/bar/bin"; LANG = "nl_NL.UTF-8"; }; description = "Environment variables passed to the service's processes."; }; diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index cf35504e5182..0393291c0c39 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -520,7 +520,7 @@ in }; systemd.globalEnvironment = mkOption { - type = with types; attrsOf (nullOr (either str (either path package))); + type = with types; attrsOf (nullOr (oneOf [ str path package ])); default = {}; example = { TZ = "CET"; }; description = '' -- cgit 1.4.1