From d4b45615886b9d0d0eb3da8254dbb3ab3f7478f8 Mon Sep 17 00:00:00 2001 From: Mikael Voss Date: Fri, 29 Nov 2024 20:42:04 +0100 Subject: [PATCH] builders: Determine qemu executable paths at build time --- pkgs/build-worker-oci/default.nix | 5 ++++- pkgs/build-worker-oci/entrypoint.sh | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/build-worker-oci/default.nix b/pkgs/build-worker-oci/default.nix index 06ce68f..040a305 100644 --- a/pkgs/build-worker-oci/default.nix +++ b/pkgs/build-worker-oci/default.nix @@ -1,5 +1,6 @@ # I hate this so much aaa { + lib, callPackage, dockerTools, openssh, @@ -95,7 +96,9 @@ dockerTools.buildLayeredImage { mkdir -p /var/empty 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 ''; } diff --git a/pkgs/build-worker-oci/entrypoint.sh b/pkgs/build-worker-oci/entrypoint.sh index 4bf14fc..4b75186 100644 --- a/pkgs/build-worker-oci/entrypoint.sh +++ b/pkgs/build-worker-oci/entrypoint.sh @@ -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_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:$(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 +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 /root/.nix-profile/bin/sshd -D -f /root/sshd_config