Closed7
NixOS on Lima
この設定ファイルを参考に、次の設定ファイルを作成した。
images:
- location: https://s3.us-west-2.amazonaws.com/static.msgilligan.com/nixos-lima/nixos-lima-unstable-aarch64.qcow2
arch: aarch64
digest: sha512:51529441cec5b90c3772f81ec5cfc09c6ce4534ac76e7cb8415df754900cc2250947df59c327d9c7dbbcb95a3dc317f0c8c55fdd3c7c00740693c3cc437f7fce
- location: https://s3.us-west-2.amazonaws.com/static.msgilligan.com/nixos-lima/nixos-lima-unstable-x86_64.qcow2
arch: x86_64
digest: sha512:5492489506bb14ace363f83d30425db48a01c379bb39a3787b914c9eac754e59326a5b424866f423c2d2e0358d0975bbf94a1cf3914e91654cc399daea1f0fe5
ssh:
forwardAgent: true
containerd:
user: false
この設定ファイルで起動すると……、
$ limactl start --name=nixos --tty=false configs/lima/nixos.yaml
INFO[0000] Terminal is not available, proceeding without opening an editor
INFO[0000] Starting the instance "nixos" with VM driver "vz"
INFO[0000] Attempting to download the image arch=aarch64 digest="sha512:51529441cec5b90c3772f81ec5cfc09c6ce4534ac76e7cb8415df754900cc2250947df59c327d9c7dbbcb95a3dc317f0c8c55fdd3c7c00740693c3cc437f7fce" location="https://s3.us-west-2.amazonaws.com/static.msgilligan.com/nixos-lima/nixos-lima-unstable-aarch64.qcow2"
Downloading the image (nixos-lima-unstable-aarch64.qcow2)
2.37 GiB / 2.37 GiB [---------------------------------------] 100.00% 2.20 MiB/s
INFO[1105] Downloaded the image from "https://s3.us-west-2.amazonaws.com/static.msgilligan.com/nixos-lima/nixos-lima-unstable-aarch64.qcow2"
INFO[1108] [hostagent] hostagent socket created at /Users/hidekazu/.lima/nixos/ha.sock
INFO[1108] [hostagent] Starting VZ (hint: to watch the boot progress, see "/Users/hidekazu/.lima/nixos/serial*.log")
INFO[1109] SSH Local Port: 58623
INFO[1108] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1108] [hostagent] [VZ] - vm state change: running
INFO[1118] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1122] [hostagent] 2025/07/17 20:17:45 tcpproxy: for incoming conn 127.0.0.1:58627, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
INFO[1131] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1135] [hostagent] 2025/07/17 20:17:58 tcpproxy: for incoming conn 127.0.0.1:58631, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
INFO[1144] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1148] [hostagent] 2025/07/17 20:18:11 tcpproxy: for incoming conn 127.0.0.1:58632, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
INFO[1157] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1161] [hostagent] 2025/07/17 20:18:24 tcpproxy: for incoming conn 127.0.0.1:58638, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
INFO[1170] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1174] [hostagent] 2025/07/17 20:18:38 tcpproxy: for incoming conn 127.0.0.1:58642, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
INFO[1184] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1187] [hostagent] 2025/07/17 20:18:51 tcpproxy: for incoming conn 127.0.0.1:58644, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
INFO[1197] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1200] [hostagent] 2025/07/17 20:19:04 tcpproxy: for incoming conn 127.0.0.1:58645, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
INFO[1210] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[1213] [hostagent] 2025/07/17 20:19:17 tcpproxy: for incoming conn 127.0.0.1:58650, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host
起動しなかった……。
vmType を qemu にしたところ、無事に起動した。
$ limactl start --name=nixos-qemu --tty=false --set '.vmType = "qemu"' configs/lima/nixos.yaml
INFO[0000] Terminal is not available, proceeding without opening an editor
INFO[0000] Starting the instance "nixos-qemu" with VM driver "qemu"
INFO[0000] QEMU binary "/opt/homebrew/bin/qemu-system-aarch64" seems properly signed with the "com.apple.security.hypervisor" entitlement
INFO[0000] Attempting to download the image arch=aarch64 digest="sha512:51529441cec5b90c3772f81ec5cfc09c6ce4534ac76e7cb8415df754900cc2250947df59c327d9c7dbbcb95a3dc317f0c8c55fdd3c7c00740693c3cc437f7fce" location="https://s3.us-west-2.amazonaws.com/static.msgilligan.com/nixos-lima/nixos-lima-unstable-aarch64.qcow2"
INFO[0000] Using cache "/Users/hidekazu/Library/Caches/lima/download/by-url-sha256/4209ac5c300499c8462b5b538ab9ae18b21c2f3babd471b34d6b423f8f62841f/data"
INFO[0000] [hostagent] hostagent socket created at /Users/hidekazu/.lima/nixos-qemu/ha.sock
INFO[0000] [hostagent] Using system firmware ("/opt/homebrew/share/qemu/edk2-aarch64-code.fd")
INFO[0000] [hostagent] Starting QEMU (hint: to watch the boot progress, see "/Users/hidekazu/.lima/nixos-qemu/serial*.log")
INFO[0000] SSH Local Port: 58737
INFO[0000] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[0010] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[0017] [hostagent] The essential requirement 1 of 2 is satisfied
INFO[0017] [hostagent] Waiting for the essential requirement 2 of 2: "user session is ready for ssh"
INFO[0017] [hostagent] The essential requirement 2 of 2 is satisfied
INFO[0017] [hostagent] Waiting for the guest agent to be running
INFO[0017] [hostagent] Forwarding "/run/lima-guestagent.sock" (guest) to "/Users/hidekazu/.lima/nixos-qemu/ga.sock" (host)
INFO[0017] [hostagent] Guest agent is running
INFO[0017] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished"
INFO[0017] [hostagent] Not forwarding TCP 0.0.0.0:22
INFO[0017] [hostagent] Not forwarding TCP [::]:22
INFO[0017] [hostagent] Not forwarding UDP 0.0.0.0:68
INFO[0017] [hostagent] The final requirement 1 of 1 is satisfied
INFO[0018] READY. Run `limactl shell nixos-qemu` to open the shell.
ディスプレイを表示した見たけど、原因が分からず……。

git diff lima.nix
diff --git a/lima.nix b/lima.nix
index 9acc2ba..ef8bb31 100644
--- a/lima.nix
+++ b/lima.nix
@@ -19,10 +19,13 @@
};
# system mounts
- boot.loader.grub = {
- device = "nodev";
- efiSupport = true;
- efiInstallAsRemovable = true;
+ boot = {
+ kernelParams = [ "console=tty0" ];
+ loader.grub = {
+ device = "nodev";
+ efiSupport = true;
+ efiInstallAsRemovable = true;
+ };
};
fileSystems."/boot" = {
device = lib.mkForce "/dev/vda1"; # /dev/disk/by-label/ESP
起動はできた!

lima-guestagent は起動している。
$ sudo systemctl status lima-guestagent.service
● lima-guestagent.service - Forward ports to the lima-hostagent
Loaded: loaded (/etc/systemd/system/lima-guestagent.service; enabled; preset: ignored)
Active: active (running) since Sat 2025-07-19 00:38:20 UTC; 2min 1s ago
Invocation: 934667db41814d0c8db3fc9f4cbfc037
Main PID: 911 (lima-guestagent)
IP: 0B in, 0B out
IO: 29.2M read, 0B written
Tasks: 7 (limit: 4613)
Memory: 34.9M (peak: 35.6M)
CPU: 30ms
CGroup: /system.slice/lima-guestagent.service
└─911 /mnt/lima-cidata/lima-guestagent daemon
Jul 19 00:38:20 nixos systemd[1]: Started Forward ports to the lima-hostagent.
Jul 19 00:38:20 nixos lima-guestagent[911]: time="2025-07-19T00:38:20Z" level=info msg="event tick: 3s"
Jul 19 00:38:20 nixos lima-guestagent[911]: time="2025-07-19T00:38:20Z" level=info msg="Enabling auditing"
Jul 19 00:38:20 nixos lima-guestagent[911]: time="2025-07-19T00:38:20Z" level=info msg="Auditing enabled (0)"
Jul 19 00:38:20 nixos lima-guestagent[911]: time="2025-07-19T00:38:20Z" level=info msg="serving the guest agent on \"/run/lima-guestagent.sock\""
Jul 19 00:38:20 nixos lima-guestagent[911]: time="2025-07-19T00:38:20Z" level=info msg="fixSystemTimeSkew(): monitoring system time skew"
Jul 19 00:38:20 nixos lima-guestagent[911]: time="2025-07-19T00:38:20Z" level=info msg="setWorthCheckingIPTablesRoutine(): monitoring netfilter >
Jul 19 00:38:20 nixos lima-guestagent[911]: time="2025-07-19T00:38:20Z" level=info msg="Monitoring kubernetes services"
$ sudo /mnt/lima-cidata/lima-guestagent --help
Do not launch manually
Usage:
lima-guestagent [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
daemon Run the daemon
help Help about any command
install-systemd Install a systemd unit (user)
Flags:
--debug Debug mode
-h, --help help for lima-guestagent
-v, --version version for lima-guestagent
Use "lima-guestagent [command] --help" for more information about a command.
$ sudo /mnt/lima-cidata/lima-guestagent daemon --help
Run the daemon
Usage:
lima-guestagent daemon [flags]
Flags:
-h, --help help for daemon
--tick duration Tick for polling events (default 3s)
--virtio-port string Use virtio server instead a UNIX socket
--vsock-port int Use vsock server instead a UNIX socket
Global Flags:
--debug Debug mode
--vsock-port が指定されていないのが原因?
git diff lima-init.nix
diff --git a/lima-init.nix b/lima-init.nix
index 25fdf94..e602fb9 100644
--- a/lima-init.nix
+++ b/lima-init.nix
@@ -143,7 +143,7 @@ in {
requires = [ "lima-init.service" ];
serviceConfig = {
Type = "simple";
- ExecStart = "${LIMA_CIDATA_MNT}/lima-guestagent daemon";
+ ExecStart = "${LIMA_CIDATA_MNT}/lima-guestagent daemon --vsock-port 2222";
Restart = "on-failure";
};
};
@@ -159,7 +159,7 @@ in {
};
networking.nat.enable = true;
-
+
environment.systemPackages = with pkgs; [
bash
sshfs
イメージを再ビルドしたら、期待通りに起動できた!
$ git diff lima-init.nix
diff --git a/lima-init.nix b/lima-init.nix
index 25fdf94..e602fb9 100644
--- a/lima-init.nix
+++ b/lima-init.nix
@@ -143,7 +143,7 @@ in {
requires = [ "lima-init.service" ];
serviceConfig = {
Type = "simple";
- ExecStart = "${LIMA_CIDATA_MNT}/lima-guestagent daemon";
+ ExecStart = "${LIMA_CIDATA_MNT}/lima-guestagent daemon --vsock-port 2222";
Restart = "on-failure";
};
};
@@ -159,7 +159,7 @@ in {
};
networking.nat.enable = true;
-
+
environment.systemPackages = with pkgs; [
bash
sshfs
PR を作成した。
このスクラップは1ヶ月前にクローズされました