builders: Determine qemu executable paths at build time

This commit is contained in:
Mikael 2024-11-29 20:42:04 +01:00
parent 71f81dbb0f
commit d4b4561588
Signed by: mikael
SSH key fingerprint: SHA256:21QyD2Meiot7jOUVitIR5YkGB/XuXdCvLW1hE6dsri0
2 changed files with 6 additions and 5 deletions

View file

@ -1,5 +1,6 @@
# I hate this so much aaa # I hate this so much aaa
{ {
lib,
callPackage, callPackage,
dockerTools, dockerTools,
openssh, openssh,
@ -95,7 +96,9 @@ dockerTools.buildLayeredImage {
mkdir -p /var/empty mkdir -p /var/empty
mkdir -p /var/log mkdir -p /var/log
cp ${./entrypoint.sh} /entrypoint.sh substitute ${./entrypoint.sh} /entrypoint.sh \
--subst-var-by qemu-aarch64 ${lib.getExe' qemu-user "qemu-aarch64"} \
--subst-var-by qemu-riscv64 ${lib.getExe' qemu-user "qemu-riscv64"}
chmod +x /entrypoint.sh chmod +x /entrypoint.sh
''; '';
} }

View file

@ -33,9 +33,7 @@ aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\x
riscv64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00' riscv64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00'
riscv64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' riscv64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
execPath() { readlink -f "$(which "$1")" } echo ":qemu-aarch64:M::$aarch64_magic:$aarch64_mask:@qemu-aarch64@:POCF" >/proc/sys/fs/binfmt_misc/register
echo ":qemu-riscv64:M::$riscv64_magic:$riscv64_mask:@qemu-riscv64@:POCF" >/proc/sys/fs/binfmt_misc/register
echo ":qemu-aarch64:M::$aarch64_magic:$aarch64_mask:$(execPath qemu-aarch64):POCF" >/proc/sys/fs/binfmt_misc/register
echo ":qemu-riscv64:M::$riscv64_magic:$riscv64_mask:$(execPath qemu-riscv64):POCF" >/proc/sys/fs/binfmt_misc/register
/root/.nix-profile/bin/sshd -D -f /root/sshd_config /root/.nix-profile/bin/sshd -D -f /root/sshd_config