Skip to content
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

makeDarwinImage: make sshListenAddr configurable #19

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion makeDarwinImage/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ in
VNC will run on port 5901
'';
};
sshListenAddr = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = lib.mdDoc ''
Address on which to listen for forwarding the VM port 22 to the host
'';
};
sshPort = lib.mkOption {
type = lib.types.port;
default = 2222;
Expand Down Expand Up @@ -95,7 +102,7 @@ in
run-macos = cfg.package.makeRunScript {
diskImage = cfg.package;
extraQemuFlags = [ "-vnc ${cfg.vncListenAddr}:${toString cfg.vncDisplayNumber}" ] ++ cfg.extraQemuFlags;
inherit (cfg) threads cores sockets mem sshPort;
inherit (cfg) threads cores sockets mem sshListenAddr sshPort;
};
in lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ (5900 + cfg.vncDisplayNumber) cfg.sshPort ];
Expand Down
3 changes: 2 additions & 1 deletion makeDarwinImage/run.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
, threads ? 4
, cores ? 2
, sockets ? 1
, sshListenAddr ? "127.0.0.1"
, sshPort ? 2222
, mem ? "6G"
, diskImage ? (makeDarwinImage {})
Expand Down Expand Up @@ -37,7 +38,7 @@ writeShellScriptBin "run-macOS.sh" ''
-device ich9-intel-hda -device hda-duplex
-drive id=OpenCoreBoot,if=virtio,snapshot=on,readonly=on,format=qcow2,file="${OpenCoreBoot}"
-drive id=MacHDD,if=virtio,file="macos-ventura.qcow2",format=qcow2
-netdev user,id=net0,hostfwd=tcp::${toString sshPort}-:22 -device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:c9:18:27
-netdev user,id=net0,hostfwd=tcp:${sshListenAddr}:${toString sshPort}-:22 -device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:c9:18:27
#-monitor stdio
-device virtio-vga
${lib.concatStringsSep " " extraQemuFlags}
Expand Down