From 8fe7cb1b3dd6db6095a56eeb71d643dcb3a1fd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 18 Aug 2025 12:32:47 +0200 Subject: [PATCH] virtiofsd: fix nix chroot store support --- flake.nix | 1 + pkgs/clan-cli/clan_cli/vms/virtiofsd.py | 11 +++++++++-- pkgs/clan-cli/flake-module.nix | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 7e92e3ec1..8f7356fdb 100644 --- a/flake.nix +++ b/flake.nix @@ -96,6 +96,7 @@ ./nixosModules/flake-module.nix ./pkgs/flake-module.nix ./templates/flake-module.nix + ./pkgs/clan-cli/clan_cli/tests/flake-module.nix ] ++ [ (if pathExists ./flakeModules/clan.nix then import ./flakeModules/clan.nix inputs.self else { }) diff --git a/pkgs/clan-cli/clan_cli/vms/virtiofsd.py b/pkgs/clan-cli/clan_cli/vms/virtiofsd.py index f010ebeed..9a5dccfdd 100644 --- a/pkgs/clan-cli/clan_cli/vms/virtiofsd.py +++ b/pkgs/clan-cli/clan_cli/vms/virtiofsd.py @@ -1,4 +1,5 @@ import contextlib +import logging import shutil import subprocess import time @@ -6,7 +7,9 @@ from collections.abc import Iterator from pathlib import Path from clan_lib.errors import ClanError -from clan_lib.nix import nix_shell +from clan_lib.nix import nix_shell, nix_test_store + +log = logging.getLogger(__name__) @contextlib.contextmanager @@ -14,6 +17,9 @@ def start_virtiofsd(socket_path: Path) -> Iterator[None]: sandbox = "namespace" if shutil.which("newuidmap") is None: sandbox = "none" + store_root = nix_test_store() or Path("/") + store = store_root / "nix" / "store" + virtiofsd = nix_shell( ["virtiofsd"], [ @@ -25,9 +31,10 @@ def start_virtiofsd(socket_path: Path) -> Iterator[None]: "--sandbox", sandbox, "--shared-dir", - "/nix/store", + str(store), ], ) + log.debug("$ {}".format(" ".join(virtiofsd))) with subprocess.Popen(virtiofsd) as proc: try: while not socket_path.exists(): diff --git a/pkgs/clan-cli/flake-module.nix b/pkgs/clan-cli/flake-module.nix index d2b045875..3213e7991 100644 --- a/pkgs/clan-cli/flake-module.nix +++ b/pkgs/clan-cli/flake-module.nix @@ -25,6 +25,7 @@ "clanServices" "pkgs/zerotierone" "pkgs/minifakeroot" + "pkgs/clan-cli/clan_cli/tests/flake-module.nix" ]; }; };