···
optionalString fixBinary "F";
in ":${name}:${type}:${offset'}:${magicOrExtension}:${mask'}:${interpreter}:${flags}";
23
-
activationSnippet = name: { interpreter, wrapInterpreterInShell, ... }: if wrapInterpreterInShell then ''
24
-
rm -f /run/binfmt/${name}
25
-
cat > /run/binfmt/${name} << 'EOF'
26
-
#!${pkgs.bash}/bin/sh
27
-
exec -- ${interpreter} "$@"
29
-
chmod +x /run/binfmt/${name}
31
-
rm -f /run/binfmt/${name}
32
-
ln -s ${interpreter} /run/binfmt/${name}
23
+
mkInterpreter = name: { interpreter, wrapInterpreterInShell, ... }:
24
+
if wrapInterpreterInShell
25
+
then pkgs.writeShellScript "${name}-interpreter" ''
26
+
#!${pkgs.bash}/bin/sh
27
+
exec -- ${interpreter} "$@"
getEmulator = system: (lib.systems.elaborate { inherit system; }).emulator pkgs;
getQemuArch = system: (lib.systems.elaborate { inherit system; }).qemuArch;
···
environment.etc."binfmt.d/nixos.conf".source = builtins.toFile "binfmt_nixos.conf"
(lib.concatStringsSep "\n" (lib.mapAttrsToList makeBinfmtLine config.boot.binfmt.registrations));
321
-
system.activationScripts.binfmt = stringAfter [ "specialfs" ] ''
322
-
mkdir -p /run/binfmt
323
-
chmod 0755 /run/binfmt
324
-
${lib.concatStringsSep "\n" (lib.mapAttrsToList activationSnippet config.boot.binfmt.registrations)}
326
-
systemd = lib.mkIf (config.boot.binfmt.registrations != {}) {
327
-
additionalUpstreamSystemUnits = [
328
-
"proc-sys-fs-binfmt_misc.automount"
329
-
"proc-sys-fs-binfmt_misc.mount"
330
-
"systemd-binfmt.service"
332
-
services.systemd-binfmt.restartTriggers = [ (builtins.toJSON config.boot.binfmt.registrations) ];
318
+
systemd = lib.mkMerge [
319
+
({ tmpfiles.rules = [
320
+
"d /run/binfmt 0755 -"
321
+
] ++ lib.mapAttrsToList
322
+
(name: interpreter:
323
+
"L+ /run/binfmt/${name} - - - - ${interpreter}"
325
+
(lib.mapAttrs mkInterpreter config.boot.binfmt.registrations);
328
+
(lib.mkIf (config.boot.binfmt.registrations != {}) {
329
+
additionalUpstreamSystemUnits = [
330
+
"proc-sys-fs-binfmt_misc.automount"
331
+
"proc-sys-fs-binfmt_misc.mount"
332
+
"systemd-binfmt.service"
334
+
services.systemd-binfmt.restartTriggers = [ (builtins.toJSON config.boot.binfmt.registrations) ];