builders: Enable user mode emulation for RISC-V and ARM
This commit is contained in:
parent
8a93fb6c56
commit
d0e97fa1ed
3 changed files with 19 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
bash,
|
bash,
|
||||||
gnused,
|
gnused,
|
||||||
util-linux,
|
util-linux,
|
||||||
|
qemu-user
|
||||||
}:
|
}:
|
||||||
|
|
||||||
dockerTools.buildLayeredImage {
|
dockerTools.buildLayeredImage {
|
||||||
|
@ -20,7 +21,7 @@ dockerTools.buildLayeredImage {
|
||||||
|
|
||||||
enableFakechroot = true;
|
enableFakechroot = true;
|
||||||
|
|
||||||
contents = [ openssh util-linux bash gnused ];
|
contents = [ openssh util-linux bash gnused qemu-user ];
|
||||||
|
|
||||||
config.Cmd = [ "/entrypoint.sh" ];
|
config.Cmd = [ "/entrypoint.sh" ];
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,16 @@ cp /root/nix.conf /etc/nix/nix.conf
|
||||||
/bin/mount -t overlay overlay -o lowerdir=/nix,upperdir=/mnt/data/nix-store,workdir=/mnt/data/workdir /nix
|
/bin/mount -t overlay overlay -o lowerdir=/nix,upperdir=/mnt/data/nix-store,workdir=/mnt/data/workdir /nix
|
||||||
/bin/mount --bind /mnt/data/tmp /tmp
|
/bin/mount --bind /mnt/data/tmp /tmp
|
||||||
|
|
||||||
|
# Register QEMU binaries for user mode emulation
|
||||||
|
aarch64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00'
|
||||||
|
aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
/root/.nix-profile/bin/sshd -D -f /root/sshd_config
|
/root/.nix-profile/bin/sshd -D -f /root/sshd_config
|
||||||
|
|
|
@ -2,7 +2,11 @@ final: prev: {
|
||||||
nyastodon = final.callPackage ./nyastodon/default.nix {};
|
nyastodon = final.callPackage ./nyastodon/default.nix {};
|
||||||
upgrade-system = final.callPackage ./upgrade-system/default.nix {};
|
upgrade-system = final.callPackage ./upgrade-system/default.nix {};
|
||||||
update-nixfiles = final.callPackage ./update-nixfiles/default.nix {};
|
update-nixfiles = final.callPackage ./update-nixfiles/default.nix {};
|
||||||
build-worker-oci = final.callPackage ./build-worker-oci/default.nix {};
|
build-worker-oci = final.callPackage ./build-worker-oci/default.nix {
|
||||||
|
qemu-user = final.pkgsStatic.qemu-user.override {
|
||||||
|
hostCpuTargets = [ "aarch64-linux-user" "riscv64-linux-user" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
librespeed-rust = final.callPackage ./librespeed-rust/default.nix {};
|
librespeed-rust = final.callPackage ./librespeed-rust/default.nix {};
|
||||||
librespeed-go = final.callPackage ./librespeed-go/default.nix {};
|
librespeed-go = final.callPackage ./librespeed-go/default.nix {};
|
||||||
akkoma-fe-domi = final.callPackage ./akkoma-fe-domi/default.nix {};
|
akkoma-fe-domi = final.callPackage ./akkoma-fe-domi/default.nix {};
|
||||||
|
|
Loading…
Reference in a new issue