add config.environment.ld-linux
Add option to install symlink to ld-linux(8) system-wide to allow running unmodified ELF binaries. It might be useful to run games or executables distributed inside jar files as discussed https://discourse.nixos.org/t/runtime-alternative-to-patchelf-set-interpreter/3539 https://discourse.nixos.org/t/running-binaries-without-fhs-and-patchelf/1828 It is the third concession to FHS after `/bin/sh` and `/usr/bin/env` but it is disabled by default unlike those two
This commit is contained in:
parent
e598c4001f
commit
af665d822a
@ -162,6 +162,16 @@ in
|
|||||||
<literal>/usr/bin/env</literal>.
|
<literal>/usr/bin/env</literal>.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.ld-linux = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
visible = false;
|
||||||
|
description = ''
|
||||||
|
Install symlink to ld-linux(8) system-wide to allow running unmodified ELF binaries.
|
||||||
|
It might be useful to run games or executables distributed inside jar files.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -198,6 +208,27 @@ in
|
|||||||
rmdir --ignore-fail-on-non-empty /usr/bin /usr
|
rmdir --ignore-fail-on-non-empty /usr/bin /usr
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
system.activationScripts.ld-linux =
|
||||||
|
concatStrings (
|
||||||
|
mapAttrsToList
|
||||||
|
(target: source:
|
||||||
|
if config.environment.ld-linux then ''
|
||||||
|
mkdir -m 0755 -p $(dirname ${target})
|
||||||
|
ln -sfn ${escapeShellArg source} ${target}.tmp
|
||||||
|
mv -f ${target}.tmp ${target} # atomically replace
|
||||||
|
'' else ''
|
||||||
|
rm -f ${target}
|
||||||
|
rmdir --ignore-fail-on-non-empty $(dirname ${target})
|
||||||
|
'')
|
||||||
|
{
|
||||||
|
"i686-linux" ."/lib/ld-linux.so.2" = "${pkgs.glibc.out}/lib/ld-linux.so.2";
|
||||||
|
"x86_64-linux" ."/lib/ld-linux.so.2" = "${pkgs.pkgsi686Linux.glibc.out}/lib/ld-linux.so.2";
|
||||||
|
"x86_64-linux" ."/lib64/ld-linux-x86-64.so.2" = "${pkgs.glibc.out}/lib64/ld-linux-x86-64.so.2";
|
||||||
|
"aarch64-linux"."/lib/ld-linux-aarch64.so.1" = "${pkgs.glibc.out}/lib/ld-linux-aarch64.so.1";
|
||||||
|
"armv7l-linux" ."/lib/ld-linux-armhf.so.3" = "${pkgs.glibc.out}/lib/ld-linux-armhf.so.3";
|
||||||
|
}.${pkgs.stdenv.system} or {}
|
||||||
|
);
|
||||||
|
|
||||||
system.activationScripts.specialfs =
|
system.activationScripts.specialfs =
|
||||||
''
|
''
|
||||||
specialMount() {
|
specialMount() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user