From 1f53a820f1570f9e75263e6a69103465e0cf2c46 Mon Sep 17 00:00:00 2001 From: r2r-dev Date: Mon, 17 May 2021 01:20:32 +0200 Subject: [PATCH] adapted M1 patches, vmnet patches, macos sdk 11.0 from thefloweringhash, xattr fixes for p9fs, fix for mkdir in qemu-vm --- README.md | 14 ++++++++++++-- examples/darwin.nix | 13 +++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ff08bec..1285c5b 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,12 @@ With following changes in place: - https://github.com/dermetfan/nixos-shell/commit/28ea39e0b76698e7dbd198e9755d7dbc12bf5146 - https://github.com/r2r-dev/nixpkgs/commit/58142a0fa46a3e920cb4e92fcd0420eeec62ae27 - https://github.com/NixOS/nixpkgs/pull/72354 +- https://mail.gnu.org/archive/html/qemu-devel/2021-02/msg04637.html +- https://patchwork.kernel.org/project/qemu-devel/patch/20210103145055.11074-1-r.bolshakov@yadro.com/ +- https://patchwork.kernel.org/project/qemu-devel/list/?series=400619&state=%2A&archive=both +- https://github.com/thefloweringash/nixpkgs/tree/apple-silicon/pkgs/os-specific/darwin/apple-sdk-11.0 +- https://github.com/thefloweringash/nixpkgs/blob/apple-silicon/pkgs/os-specific/darwin/rewrite-tbd/default.nix + It is possible to use nixos-shell on darwin host. Word of notice, you will need a remote x86_64-linux builder in order to produce a VM image. @@ -229,8 +235,12 @@ It is possible to use nixos-shell on darwin host. Word of notice, you will need # Install nixos-shell from source: nix-env -i -f . -# Run darwin example: -nixos-shell examples/darwin.nix -- -- --argstr system x86_64-linux -I nixpkgs=http://github.com/r2r-dev/nixpkgs/archive/58142a0fa46a3e920cb4e92fcd0420eeec62ae27.tar.gz +# Build darwin example: +nixos-shell examples/darwin.nix -- -- --argstr system x86_64-linux -I nixpkgs=http://github.com/r2r-dev/nixpkgs/archive/f68911645209742013dd6abe570a23548d9a5780.tar.gz --option builders-use-substitutes true + +# Grab build output and run is as root (if you wish to use vmnet) +sudo /nix/store/somehash-nixos-vm/bin/run-nixos-vm + ``` ## More configuration diff --git a/examples/darwin.nix b/examples/darwin.nix index cdd68a7..21ab4e9 100644 --- a/examples/darwin.nix +++ b/examples/darwin.nix @@ -39,15 +39,24 @@ shareExchangeDir = true; qemu = { + options = [ "-accel hvf" ]; + # use vmnet adapter networkingOptions = [ - "-net nic,netdev=user.0,model=virtio" - "-netdev user,id=user.0,hostfwd=tcp::2222-:22" + "-net nic,model=virtio,netdev=hn0" + "-netdev vmnet-macos,id=hn0,mode=bridged,ifname=en8" ]; pkgs = import { system = "x86_64-darwin"; overlays = [ (self: super: { qemu = super.qemu.overrideAttrs (attrs: { + buildInputs = attrs.buildInputs + ++ [ super.darwin.apple_sdk_11.frameworks.vmnet ]; + sandboxProfile = '' + (allow file-read* file-write* process-exec mach-lookup) + ; block homebrew dependencies + (deny file-read* file-write* process-exec mach-lookup (subpath "/usr/local") (with no-log)) + ''; preConfigure = attrs.preConfigure + "substituteInPlace meson.build --replace 'if exe_sign' 'if false'"; });