1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-19 12:11:28 +00:00

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
This commit is contained in:
Matthew Bauer 2020-12-31 13:28:01 -06:00
parent 2f47650c2f
commit 08135a3caa

View file

@ -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;