-
-
Notifications
You must be signed in to change notification settings - Fork 147
Darwin support #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
esselius
wants to merge
1
commit into
microvm-nix:main
Choose a base branch
from
esselius:darwin-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Darwin support #397
+117
−82
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apple users, please review and test |
I gave this a try on my M3 MBP and seems to work well! I took the default flake template and tweaked slightly: {
description = "NixOS in MicroVMs";
nixConfig = {
extra-substituters = ["https://microvm.cachix.org"];
extra-trusted-public-keys = ["microvm.cachix.org-1:oXnBc6hRE3eX5rSYdRyMYXnfzcCxC7yKPTbZXALsqys="];
};
inputs.microvm = {
url = "github:microvm-nix/microvm.nix/pull/397/head";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
microvm,
}: let
system = "aarch64-darwin"; # <-- switched to Darwin
in {
packages.${system} = {
default = self.packages.${system}.my-microvm;
my-microvm = self.nixosConfigurations.my-microvm.config.microvm.declaredRunner;
};
nixosConfigurations = {
my-microvm = nixpkgs.lib.nixosSystem {
system = "aarch64-linux"; # <-- explicitly set
modules = [
microvm.nixosModules.microvm
{
networking.hostName = "my-microvm";
users.users.root.password = "";
microvm = {
vmHostPackages = nixpkgs.legacyPackages.aarch64-darwin.pkgs; # <-- added as per the PR
volumes = [
{
mountPoint = "/var";
image = "var.img";
size = 256;
}
];
shares = [
{
# use proto = "virtiofs" for MicroVMs that are started by systemd
proto = "9p";
tag = "ro-store";
# a host's /nix/store will be picked up so that no
# squashfs/erofs will be built for it.
source = "/nix/store";
mountPoint = "/nix/.ro-store";
}
];
# "qemu" has 9p built-in!
hypervisor = "qemu";
socket = "control.socket";
};
}
];
};
};
};
} Running Full output:
Building from a different configuration via the nix-darwin linux builder also works as expected: Flake:{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
microvm = {
url = "github:microvm-nix/microvm.nix/pull/397/head";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs: {
nixosConfigurations.vm = inputs.nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
inputs.microvm.nixosModules.microvm
{
networking.hostName = "vm";
users.users.root.password = "";
microvm = {
hypervisor = "qemu";
socket = "control.socket";
vmHostPackages = inputs.nixpkgs.legacyPackages.aarch64-darwin.pkgs;
mem = 1024;
vcpu = 1;
shares = [
{
proto = "9p";
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
}
];
};
system.stateVersion = "25.11";
services.getty.autologinUser = "root";
}
];
};
};
} Full output:
EDIT TO ADD: This also works as expected using nixbuild.net as a remote builder. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Almost 1:1 copy of #373 with very minor changes, seems to work as expected :)