git.iko.soy/typeable/nixpkgs
on master help sign in
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

commit08135a3caa45ed8d278099b60d64bdaf6987d5b9 authorMatthew Bauer <mjbauer95@gmail.com> dateThu 31 Dec 2020, 13:28 (6 years ago) parent2f47650
1 file changed+8−2
nixos/modules/system/boot/binfmt.nix+8−2
nixos/modules/system/boot/binfmt.nix+8−2
@@ -20,8 +20,14 @@ let
2020 optionalString fixBinary "F";
2121 in ":${name}:${type}:${offset'}:${magicOrExtension}:${mask'}:${interpreter}:${flags}";
2222
23− activationSnippet = name: { interpreter, ... }:
24− "ln -sf ${interpreter} /run/binfmt/${name}";
23+ activationSnippet = name: { interpreter, ... }: ''
24+ rm -f /run/binfmt/${name}
25+ cat > /run/binfmt/${name} << 'EOF'
26+ #!/usr/bin/env sh
27+ exec -- ${interpreter} "$@"
28+ EOF
29+ chmod +x /run/binfmt/${name}
30+ '';
2531
2632 getEmulator = system: (lib.systems.elaborate { inherit system; }).emulator pkgs;
2733