2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit (lib) mkOption mkDefault types optionalString;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cfg = config.boot.binfmt;
|
|
|
|
|
|
|
|
makeBinfmtLine = name: { recognitionType, offset, magicOrExtension
|
|
|
|
, mask, preserveArgvZero, openBinary
|
|
|
|
, matchCredentials, fixBinary, ...
|
|
|
|
}: let
|
|
|
|
type = if recognitionType == "magic" then "M" else "E";
|
|
|
|
offset' = toString offset;
|
|
|
|
mask' = toString mask;
|
|
|
|
interpreter = "/run/binfmt/${name}";
|
|
|
|
flags = if !(matchCredentials -> openBinary)
|
|
|
|
then throw "boot.binfmt.registrations.${name}: you can't specify openBinary = false when matchCredentials = true."
|
|
|
|
else optionalString preserveArgvZero "P" +
|
|
|
|
optionalString (openBinary && !matchCredentials) "O" +
|
|
|
|
optionalString matchCredentials "C" +
|
|
|
|
optionalString fixBinary "F";
|
|
|
|
in ":${name}:${type}:${offset'}:${magicOrExtension}:${mask'}:${interpreter}:${flags}";
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
mkInterpreter = name: { interpreter, wrapInterpreterInShell, ... }:
|
|
|
|
if wrapInterpreterInShell
|
|
|
|
then pkgs.writeShellScript "${name}-interpreter" ''
|
|
|
|
#!${pkgs.bash}/bin/sh
|
|
|
|
exec -- ${interpreter} "$@"
|
|
|
|
''
|
|
|
|
else interpreter;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
getEmulator = system: (lib.systems.elaborate { inherit system; }).emulator pkgs;
|
2022-01-07 04:07:37 +00:00
|
|
|
getQemuArch = system: (lib.systems.elaborate { inherit system; }).qemuArch;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Mapping of systems to “magicOrExtension” and “mask”. Mostly taken from:
|
|
|
|
# - https://github.com/cleverca22/nixos-configs/blob/master/qemu.nix
|
|
|
|
# and
|
|
|
|
# - https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh
|
|
|
|
# TODO: maybe put these in a JSON file?
|
|
|
|
magics = {
|
|
|
|
armv6l-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
armv7l-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
aarch64-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
aarch64_be-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'';
|
|
|
|
};
|
|
|
|
i386-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
i486-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
i586-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
i686-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
x86_64-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
alpha-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
sparc64-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'';
|
|
|
|
};
|
|
|
|
sparc-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'';
|
|
|
|
};
|
|
|
|
powerpc-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'';
|
|
|
|
};
|
|
|
|
powerpc64-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'';
|
|
|
|
};
|
|
|
|
powerpc64le-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'';
|
|
|
|
};
|
|
|
|
mips-linux = {
|
2023-10-09 19:29:22 +00:00
|
|
|
magicOrExtension = ''\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
mipsel-linux = {
|
2023-10-09 19:29:22 +00:00
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
mips64-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'';
|
2023-10-09 19:29:22 +00:00
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
mips64el-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'';
|
2023-10-09 19:29:22 +00:00
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
mips64-linuxabin32 = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'';
|
|
|
|
};
|
|
|
|
mips64el-linuxabin32 = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'';
|
|
|
|
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
riscv32-linux = {
|
|
|
|
magicOrExtension = ''\x7fELF\x01\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'';
|
|
|
|
};
|
|
|
|
riscv64-linux = {
|
|
|
|
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'';
|
|
|
|
};
|
2023-04-29 16:46:19 +00:00
|
|
|
loongarch64-linux = {
|
|
|
|
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'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
wasm32-wasi = {
|
|
|
|
magicOrExtension = ''\x00asm'';
|
|
|
|
mask = ''\xff\xff\xff\xff'';
|
|
|
|
};
|
|
|
|
wasm64-wasi = {
|
|
|
|
magicOrExtension = ''\x00asm'';
|
|
|
|
mask = ''\xff\xff\xff\xff'';
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
x86_64-windows.magicOrExtension = "MZ";
|
|
|
|
i686-windows.magicOrExtension = "MZ";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
imports = [
|
|
|
|
(lib.mkRenamedOptionModule [ "boot" "binfmtMiscRegistrations" ] [ "boot" "binfmt" "registrations" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
boot.binfmt = {
|
|
|
|
registrations = mkOption {
|
|
|
|
default = {};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Extra binary formats to register with the kernel.
|
|
|
|
See https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html for more details.
|
|
|
|
'';
|
|
|
|
|
|
|
|
type = types.attrsOf (types.submodule ({ config, ... }: {
|
|
|
|
options = {
|
|
|
|
recognitionType = mkOption {
|
|
|
|
default = "magic";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Whether to recognize executables by magic number or extension.";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.enum [ "magic" "extension" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
offset = mkOption {
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The byte offset of the magic number used for recognition.";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.nullOr types.int;
|
|
|
|
};
|
|
|
|
|
|
|
|
magicOrExtension = mkOption {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The magic number or extension to match on.";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
mask = mkOption {
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "A mask to be ANDed with the byte sequence of the file before matching";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
interpreter = mkOption {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The interpreter to invoke to run the program.
|
|
|
|
|
|
|
|
Note that the actual registration will point to
|
|
|
|
/run/binfmt/''${name}, so the kernel interpreter length
|
|
|
|
limit doesn't apply.
|
|
|
|
'';
|
|
|
|
type = types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
preserveArgvZero = mkOption {
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to pass the original argv[0] to the interpreter.
|
|
|
|
|
|
|
|
See the description of the 'P' flag in the kernel docs
|
|
|
|
for more details;
|
|
|
|
'';
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
openBinary = mkOption {
|
|
|
|
default = config.matchCredentials;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to pass the binary to the interpreter as an open
|
|
|
|
file descriptor, instead of a path.
|
|
|
|
'';
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
matchCredentials = mkOption {
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to launch with the credentials and security
|
|
|
|
token of the binary, not the interpreter (e.g. setuid
|
|
|
|
bit).
|
|
|
|
|
|
|
|
See the description of the 'C' flag in the kernel docs
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
Implies/requires openBinary = true.
|
|
|
|
'';
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
fixBinary = mkOption {
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to open the interpreter file as soon as the
|
|
|
|
registration is loaded, rather than waiting for a
|
|
|
|
relevant file to be invoked.
|
|
|
|
|
|
|
|
See the description of the 'F' flag in the kernel docs
|
|
|
|
for more details.
|
|
|
|
'';
|
|
|
|
type = types.bool;
|
|
|
|
};
|
2022-01-07 04:07:37 +00:00
|
|
|
|
|
|
|
wrapInterpreterInShell = mkOption {
|
|
|
|
default = true;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-01-07 04:07:37 +00:00
|
|
|
Whether to wrap the interpreter in a shell script.
|
|
|
|
|
|
|
|
This allows a shell command to be set as the interpreter.
|
|
|
|
'';
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
interpreterSandboxPath = mkOption {
|
|
|
|
internal = true;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-01-07 04:07:37 +00:00
|
|
|
Path of the interpreter to expose in the build sandbox.
|
|
|
|
'';
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
emulatedSystems = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [ "wasm32-wasi" "x86_64-windows" "aarch64-linux" ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
List of systems to emulate. Will also configure Nix to
|
|
|
|
support your new systems.
|
2021-12-06 16:07:01 +00:00
|
|
|
Warning: the builder can execute all emulated systems within the same build, which introduces impurities in the case of cross compilation.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2023-10-09 19:29:22 +00:00
|
|
|
type = types.listOf (types.enum (builtins.attrNames magics));
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
boot.binfmt.registrations = builtins.listToAttrs (map (system: {
|
|
|
|
name = system;
|
2022-12-28 21:21:41 +00:00
|
|
|
value = { config, ... }: let
|
2020-04-24 23:36:52 +00:00
|
|
|
interpreter = getEmulator system;
|
2022-01-07 04:07:37 +00:00
|
|
|
qemuArch = getQemuArch system;
|
|
|
|
|
|
|
|
preserveArgvZero = "qemu-${qemuArch}" == baseNameOf interpreter;
|
|
|
|
interpreterReg = let
|
|
|
|
wrapperName = "qemu-${qemuArch}-binfmt-P";
|
|
|
|
wrapper = pkgs.wrapQemuBinfmtP wrapperName interpreter;
|
|
|
|
in
|
|
|
|
if preserveArgvZero then "${wrapper}/bin/${wrapperName}"
|
|
|
|
else interpreter;
|
2022-12-28 21:21:41 +00:00
|
|
|
in ({
|
|
|
|
preserveArgvZero = mkDefault preserveArgvZero;
|
2022-01-07 04:07:37 +00:00
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
interpreter = mkDefault interpreterReg;
|
|
|
|
wrapInterpreterInShell = mkDefault (!config.preserveArgvZero);
|
|
|
|
interpreterSandboxPath = mkDefault (dirOf (dirOf config.interpreter));
|
|
|
|
} // (magics.${system} or (throw "Cannot create binfmt registration for system ${system}")));
|
2020-04-24 23:36:52 +00:00
|
|
|
}) cfg.emulatedSystems);
|
2022-01-27 00:19:43 +00:00
|
|
|
nix.settings = lib.mkIf (cfg.emulatedSystems != []) {
|
|
|
|
extra-platforms = cfg.emulatedSystems ++ lib.optional pkgs.stdenv.hostPlatform.isx86_64 "i686-linux";
|
|
|
|
extra-sandbox-paths = let
|
2022-01-07 04:07:37 +00:00
|
|
|
ruleFor = system: cfg.registrations.${system};
|
|
|
|
hasWrappedRule = lib.any (system: (ruleFor system).wrapInterpreterInShell) cfg.emulatedSystems;
|
|
|
|
in [ "/run/binfmt" ]
|
|
|
|
++ lib.optional hasWrappedRule "${pkgs.bash}"
|
2022-01-27 00:19:43 +00:00
|
|
|
++ (map (system: (ruleFor system).interpreterSandboxPath) cfg.emulatedSystems);
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
environment.etc."binfmt.d/nixos.conf".source = builtins.toFile "binfmt_nixos.conf"
|
|
|
|
(lib.concatStringsSep "\n" (lib.mapAttrsToList makeBinfmtLine config.boot.binfmt.registrations));
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
systemd = lib.mkMerge [
|
|
|
|
({ tmpfiles.rules = [
|
|
|
|
"d /run/binfmt 0755 -"
|
|
|
|
] ++ lib.mapAttrsToList
|
|
|
|
(name: interpreter:
|
|
|
|
"L+ /run/binfmt/${name} - - - - ${interpreter}"
|
|
|
|
)
|
|
|
|
(lib.mapAttrs mkInterpreter config.boot.binfmt.registrations);
|
|
|
|
})
|
|
|
|
|
|
|
|
(lib.mkIf (config.boot.binfmt.registrations != {}) {
|
|
|
|
additionalUpstreamSystemUnits = [
|
|
|
|
"proc-sys-fs-binfmt_misc.automount"
|
|
|
|
"proc-sys-fs-binfmt_misc.mount"
|
|
|
|
"systemd-binfmt.service"
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
services.systemd-binfmt.after = [ "systemd-tmpfiles-setup.service" ];
|
2023-11-16 04:20:00 +00:00
|
|
|
services.systemd-binfmt.restartTriggers = [ (builtins.toJSON config.boot.binfmt.registrations) ];
|
|
|
|
})
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|