From 08135a3caa45ed8d278099b60d64bdaf6987d5b9 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 31 Dec 2020 13:28:01 -0600 Subject: nixos/binfmt.nix: fix running commands in binfmt To allow arguments in binfmt, we need to put the command in a shell script. This uses exec to run the binfmt interpreter. Fixes #90683 --- nixos/modules/system/boot/binfmt.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'nixos/modules/system/boot/binfmt.nix') diff --git a/nixos/modules/system/boot/binfmt.nix b/nixos/modules/system/boot/binfmt.nix index 9eeae0c3ef44..5bcc95be324a 100644 --- a/nixos/modules/system/boot/binfmt.nix +++ b/nixos/modules/system/boot/binfmt.nix @@ -20,8 +20,14 @@ let optionalString fixBinary "F"; in ":${name}:${type}:${offset'}:${magicOrExtension}:${mask'}:${interpreter}:${flags}"; - activationSnippet = name: { interpreter, ... }: - "ln -sf ${interpreter} /run/binfmt/${name}"; + activationSnippet = name: { interpreter, ... }: '' + rm -f /run/binfmt/${name} + cat > /run/binfmt/${name} << 'EOF' + #!/usr/bin/env sh + exec -- ${interpreter} "$@" + EOF + chmod +x /run/binfmt/${name} + ''; getEmulator = system: (lib.systems.elaborate { inherit system; }).emulator pkgs; -- cgit v1.2.3