Skip to content

Commit

Permalink
Merge pull request #19 from Luflosi/make-sshListenAddr-configurable
Browse files Browse the repository at this point in the history
makeDarwinImage: make sshListenAddr configurable
  • Loading branch information
MatthewCroughan authored Feb 16, 2024
2 parents 95a8003 + b1cf30a commit 62ba30e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 62ba30e

Please sign in to comment.