virtiofsd: fix nix chroot store support

This commit is contained in:
Jörg Thalheim
2025-08-18 12:32:47 +02:00
parent 815c6c9438
commit 8fe7cb1b3d
3 changed files with 11 additions and 2 deletions

View File

@@ -96,6 +96,7 @@
./nixosModules/flake-module.nix ./nixosModules/flake-module.nix
./pkgs/flake-module.nix ./pkgs/flake-module.nix
./templates/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 { }) (if pathExists ./flakeModules/clan.nix then import ./flakeModules/clan.nix inputs.self else { })

View File

@@ -1,4 +1,5 @@
import contextlib import contextlib
import logging
import shutil import shutil
import subprocess import subprocess
import time import time
@@ -6,7 +7,9 @@ from collections.abc import Iterator
from pathlib import Path from pathlib import Path
from clan_lib.errors import ClanError 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 @contextlib.contextmanager
@@ -14,6 +17,9 @@ def start_virtiofsd(socket_path: Path) -> Iterator[None]:
sandbox = "namespace" sandbox = "namespace"
if shutil.which("newuidmap") is None: if shutil.which("newuidmap") is None:
sandbox = "none" sandbox = "none"
store_root = nix_test_store() or Path("/")
store = store_root / "nix" / "store"
virtiofsd = nix_shell( virtiofsd = nix_shell(
["virtiofsd"], ["virtiofsd"],
[ [
@@ -25,9 +31,10 @@ def start_virtiofsd(socket_path: Path) -> Iterator[None]:
"--sandbox", "--sandbox",
sandbox, sandbox,
"--shared-dir", "--shared-dir",
"/nix/store", str(store),
], ],
) )
log.debug("$ {}".format(" ".join(virtiofsd)))
with subprocess.Popen(virtiofsd) as proc: with subprocess.Popen(virtiofsd) as proc:
try: try:
while not socket_path.exists(): while not socket_path.exists():

View File

@@ -25,6 +25,7 @@
"clanServices" "clanServices"
"pkgs/zerotierone" "pkgs/zerotierone"
"pkgs/minifakeroot" "pkgs/minifakeroot"
"pkgs/clan-cli/clan_cli/tests/flake-module.nix"
]; ];
}; };
}; };