From 3f0b00ff24c6b92328241a6284d951ce41062120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Sun, 15 Mar 2026 10:05:06 +0100 Subject: [PATCH] wip --- hosts/ephvm/configuration.nix | 23 +++++------------------ scripts/ephvm-run.sh | 25 ++++++++++++------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/hosts/ephvm/configuration.nix b/hosts/ephvm/configuration.nix index 406d7be..fc4d6d5 100644 --- a/hosts/ephvm/configuration.nix +++ b/hosts/ephvm/configuration.nix @@ -58,8 +58,11 @@ neovim.dotfiles = inputs.nvim; }; + # ensure .config exists with correct ownership before automount + systemd.tmpfiles.rules = [ "d /home/matej/.config 0755 matej users -" ]; + # writable claude config via 9p - fileSystems."/home/matej/.claude" = { + fileSystems."/home/matej/.config/claude" = { device = "claude"; fsType = "9p"; options = [ @@ -70,23 +73,7 @@ ]; }; - # .claude.json passed via qemu fw_cfg - boot.kernelModules = [ "qemu_fw_cfg" ]; - systemd.services.claude-json = { - after = [ "systemd-modules-load.service" ]; - wants = [ "systemd-modules-load.service" ]; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - ExecStart = pkgs.writeShellScript "claude-json" '' - src="/sys/firmware/qemu_fw_cfg/by_name/opt/claude.json/raw" - [ -f "$src" ] || exit 0 - cp "$src" /home/matej/.claude.json - chown matej:users /home/matej/.claude.json - ''; - }; - }; + environment.sessionVariables.CLAUDE_CONFIG_DIR = "/home/matej/.config/claude"; system.stateVersion = "25.11"; } diff --git a/scripts/ephvm-run.sh b/scripts/ephvm-run.sh index 5c254ce..3a627db 100755 --- a/scripts/ephvm-run.sh +++ b/scripts/ephvm-run.sh @@ -5,8 +5,7 @@ SSH_PORT=2222 MEMORY=8G CPUS=4 MOUNTS=() -CLAUDE_DIR="" -CLAUDE_JSON="" +CLAUDE=false IMAGE="" usage() { @@ -15,8 +14,7 @@ Usage: ephvm-run.sh [options] Options: --mount Mount host directory into VM (repeatable) - --claude Mount claude config dir writable into VM - --claude-json Copy claude.json into mounted claude dir + --claude Mount claude config dir (auto-detects from CLAUDE_CONFIG_DIR or ~/.claude) --memory VM memory (default: 8G) --cpus VM CPUs (default: 4) --ssh-port SSH port forward (default: 2222) @@ -32,8 +30,7 @@ shift while [ $# -gt 0 ]; do case "$1" in --mount) MOUNTS+=("$2"); shift 2 ;; - --claude) CLAUDE_DIR="$2"; shift 2 ;; - --claude-json) CLAUDE_JSON="$2"; shift 2 ;; + --claude) CLAUDE=true; shift ;; --memory) MEMORY="$2"; shift 2 ;; --cpus) CPUS="$2"; shift 2 ;; --ssh-port) SSH_PORT="$2"; shift 2 ;; @@ -73,15 +70,17 @@ for mount_path in "${MOUNTS[@]}"; do FS_ID=$((FS_ID + 1)) done -if [ -n "$CLAUDE_DIR" ]; then - CLAUDE_DIR=$(realpath "$CLAUDE_DIR") +if [ "$CLAUDE" = true ]; then + if [ -z "${CLAUDE_CONFIG_DIR:-}" ]; then + echo "error: --claude requires CLAUDE_CONFIG_DIR to be set" + exit 1 + fi + mkdir -p "$CLAUDE_CONFIG_DIR" + claude_dir=$(realpath "$CLAUDE_CONFIG_DIR") + QEMU_ARGS+=( - -virtfs "local,path=$CLAUDE_DIR,mount_tag=claude,security_model=none,id=fs${FS_ID}" + -virtfs "local,path=$claude_dir,mount_tag=claude,security_model=none,id=fs${FS_ID}" ) fi -if [ -n "$CLAUDE_JSON" ]; then - QEMU_ARGS+=(-fw_cfg "name=opt/claude.json,file=$CLAUDE_JSON") -fi - exec "${QEMU_ARGS[@]}"