Skip to content

Instantly share code, notes, and snippets.

@edef1c
Last active July 12, 2023 10:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edef1c/619f262854829ceab306686a342fa4a4 to your computer and use it in GitHub Desktop.
Save edef1c/619f262854829ceab306686a342fa4a4 to your computer and use it in GitHub Desktop.
NixOS module for qemu-user binfmt_misc
{ pkgs, ... }:
let inherit (pkgs) stdenv qemu getopt; in
{
systemd.additionalUpstreamSystemUnits = [
"proc-sys-fs-binfmt_misc.automount"
"proc-sys-fs-binfmt_misc.mount"
];
environment.etc."binfmt.d/qemu-user.conf".source = stdenv.mkDerivation {
name = "qemu-binfmt";
inherit (qemu) src;
buildInputs = [ getopt ];
configurePhase = ''
patchShebangs scripts/qemu-binfmt-conf.sh
'';
buildPhase = ''
mkdir binfmt
scripts/qemu-binfmt-conf.sh --qemu-path ${qemu}/bin --systemd ALL --exportdir=binfmt
'';
installPhase = ''
cat binfmt/*.conf > $out
'';
};
nix = {
sandboxPaths = [ "${qemu}" ];
extraOptions = ''
extra-platforms = i686-linux aarch64-linux armv5tel-linux armv6l-linux armv7l-linux mips64-linux mipsel-linux
'';
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment