Compare commits

3 Commits

Author SHA1 Message Date
ad2c79e113 feat: add presenterm 2026-03-18 00:50:39 +01:00
b19305f198 chore: bump lockfile 2026-03-17 11:28:39 +01:00
1975659715 feat: ephvm improvements 2026-03-16 09:49:55 +01:00
6 changed files with 62 additions and 78 deletions

48
flake.lock generated
View File

@@ -255,11 +255,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1772985280, "lastModified": 1773681845,
"narHash": "sha256-FdrNykOoY9VStevU4zjSUdvsL9SzJTcXt4omdEDZDLk=", "narHash": "sha256-o8hrZrigP0JYcwnglCp8Zi8jQafWsxbDtRRPzuVwFxY=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "8f736f007139d7f70752657dff6a401a585d6cbc", "rev": "0759e0e137305bc9d0c52c204c6d8dffe6f601a6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -300,11 +300,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1773273897, "lastModified": 1773705884,
"narHash": "sha256-S6r4raWL96DNO8nPP2whq8STG8SI8JDlyEuy1N6SvV8=", "narHash": "sha256-2atzXVl7CB+46HcuFRe3cUleEJdn2KoUdVOPQHyZBpg=",
"owner": "nix-community", "owner": "nix-community",
"repo": "neovim-nightly-overlay", "repo": "neovim-nightly-overlay",
"rev": "f165d4768ca760f4c98b63286562b6fa79a8b114", "rev": "3c143994a616ebc45c69dfa0487e171b7b5c0da6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -316,11 +316,11 @@
"neovim-src": { "neovim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1773273300, "lastModified": 1773702732,
"narHash": "sha256-PzRI/GS7+4wz+dgqWq4X2biKtJc8WgUqS6jWk0fXmlM=", "narHash": "sha256-1Oi7ygsg3ExZGMF4/VBVTDJMz27uM14kSwx7EUkte6Q=",
"owner": "neovim", "owner": "neovim",
"repo": "neovim", "repo": "neovim",
"rev": "99a0b2f7b86d447af752ee7436dd5fd69fc6a101", "rev": "6edae880528b7a1494a7610b07e4415d68c463ff",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -331,11 +331,11 @@
}, },
"nixos-hardware": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1772972630, "lastModified": 1773533765,
"narHash": "sha256-mUJxsNOrBMNOUJzN0pfdVJ1r2pxeqm9gI/yIKXzVVbk=", "narHash": "sha256-qonGfS2lzCgCl59Zl63jF6dIRRpvW3AJooBGMaXjHiY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "3966ce987e1a9a164205ac8259a5fe8a64528f72", "rev": "f8e82243fd601afb9f59ad230958bd073795cbfe",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -347,11 +347,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1773110118, "lastModified": 1773597492,
"narHash": "sha256-mPAG8phMbCReKSiKAijjjd3v7uVcJOQ75gSjGJjt/Rk=", "narHash": "sha256-hQ284SkIeNaeyud+LS0WVLX+WL2rxcVZLFEaK0e03zg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e607cb5360ff1234862ac9f8839522becb853bb9", "rev": "a07d4ce6bee67d7c838a8a5796e75dff9caa21ef",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -363,11 +363,11 @@
}, },
"nixpkgs-master": { "nixpkgs-master": {
"locked": { "locked": {
"lastModified": 1773329519, "lastModified": 1773741769,
"narHash": "sha256-TZEGtZNt1AsC6AFcELQMLZnjBwJ1ml5UdQY+iowLSTc=", "narHash": "sha256-+MzmtY3L1j67FsxeG3KJpWRbt8zbrh1Mm5lH50FWLTg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c5c2ad09ebacd0573d60c5f77ee03acc6da03fae", "rev": "33870c677e3f6e50437d5879555a9b329c145411",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -379,11 +379,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1773201692, "lastModified": 1773597492,
"narHash": "sha256-NXrKzNMniu4Oam2kAFvqJ3GB2kAvlAFIriTAheaY8hw=", "narHash": "sha256-hQ284SkIeNaeyud+LS0WVLX+WL2rxcVZLFEaK0e03zg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b6067cc0127d4db9c26c79e4de0513e58d0c40c9", "rev": "a07d4ce6bee67d7c838a8a5796e75dff9caa21ef",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -395,11 +395,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1772822230, "lastModified": 1773705440,
"narHash": "sha256-yf3iYLGbGVlIthlQIk5/4/EQDZNNEmuqKZkQssMljuw=", "narHash": "sha256-xB30bbAp0e7ogSEYyc126mAJMt4FRFh8wtm6ADE1xuM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "71caefce12ba78d84fe618cf61644dce01cf3a96", "rev": "48652e9d5aea46e555b3df87354280d4f29cd3a3",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -58,8 +58,11 @@
neovim.dotfiles = inputs.nvim; 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 # writable claude config via 9p
fileSystems."/home/matej/.claude" = { fileSystems."/home/matej/.config/claude" = {
device = "claude"; device = "claude";
fsType = "9p"; fsType = "9p";
options = [ options = [
@@ -70,23 +73,7 @@
]; ];
}; };
# .claude.json passed via qemu fw_cfg environment.sessionVariables.CLAUDE_CONFIG_DIR = "/home/matej/.config/claude";
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
'';
};
};
system.stateVersion = "25.11"; system.stateVersion = "25.11";
} }

View File

@@ -33,13 +33,9 @@ build:
iso: iso:
nixos-rebuild build-image --image-variant iso-installer --flake .#iso nixos-rebuild build-image --image-variant iso-installer --flake .#iso
# build ephemeral VM image
ephvm-build:
nixos-rebuild build-image --image-variant qemu --flake .#ephvm
# run ephemeral VM # run ephemeral VM
ephvm-run *ARGS: ephvm *ARGS:
bash scripts/ephvm-run.sh $(find -L result -name '*.qcow2' | head -1) {{ARGS}} bash scripts/ephvm-run.sh {{ARGS}}
# ssh into running ephemeral VM # ssh into running ephemeral VM
ephvm-ssh port="2222": ephvm-ssh port="2222":

View File

@@ -27,6 +27,7 @@ in
pkgs.google-cloud-sql-proxy pkgs.google-cloud-sql-proxy
packages.ahab packages.ahab
pkgs.just pkgs.just
pkgs.presenterm
]; ];
programs.direnv = { programs.direnv = {

View File

@@ -20,7 +20,7 @@ in
prefix = lib.mkOption { prefix = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "mount_"; default = "m_";
description = "9p mount tag prefix to match"; description = "9p mount tag prefix to match";
}; };

View File

@@ -5,18 +5,15 @@ SSH_PORT=2222
MEMORY=8G MEMORY=8G
CPUS=4 CPUS=4
MOUNTS=() MOUNTS=()
CLAUDE_DIR="" CLAUDE=false
CLAUDE_JSON=""
IMAGE=""
usage() { usage() {
cat <<EOF cat <<EOF
Usage: ephvm-run.sh <image.qcow2> [options] Usage: ephvm-run.sh [options]
Options: Options:
--mount <path> Mount host directory into VM (repeatable) --mount <path> Mount host directory into VM (repeatable)
--claude <path> Mount claude config dir writable into VM --claude Mount claude config dir (requires CLAUDE_CONFIG_DIR)
--claude-json <path> Copy claude.json into mounted claude dir
--memory <size> VM memory (default: 8G) --memory <size> VM memory (default: 8G)
--cpus <n> VM CPUs (default: 4) --cpus <n> VM CPUs (default: 4)
--ssh-port <port> SSH port forward (default: 2222) --ssh-port <port> SSH port forward (default: 2222)
@@ -24,25 +21,24 @@ EOF
exit 1 exit 1
} }
[ "${1:-}" ] || usage
IMAGE="$1"
shift
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
--mount) MOUNTS+=("$2"); shift 2 ;; --mount) MOUNTS+=("$2"); shift 2 ;;
--claude) CLAUDE_DIR="$2"; shift 2 ;; --claude) CLAUDE=true; shift ;;
--claude-json) CLAUDE_JSON="$2"; shift 2 ;;
--memory) MEMORY="$2"; shift 2 ;; --memory) MEMORY="$2"; shift 2 ;;
--cpus) CPUS="$2"; shift 2 ;; --cpus) CPUS="$2"; shift 2 ;;
--ssh-port) SSH_PORT="$2"; shift 2 ;; --ssh-port) SSH_PORT="$2"; shift 2 ;;
-h|--help) usage ;;
*) echo "unknown option: $1"; usage ;; *) echo "unknown option: $1"; usage ;;
esac esac
done done
if [ ! -f "$IMAGE" ]; then echo "building ephvm image..."
echo "error: image not found: $IMAGE" IMAGE_DIR=$(nix build --no-link --print-out-paths .#nixosConfigurations.ephvm.config.system.build.images.qemu)
IMAGE=$(find "$IMAGE_DIR" -name '*.qcow2' -print -quit)
if [ -z "$IMAGE" ]; then
echo "error: no qcow2 image found in $IMAGE_DIR"
exit 1 exit 1
fi fi
@@ -67,21 +63,25 @@ FS_ID=0
for mount_path in "${MOUNTS[@]}"; do for mount_path in "${MOUNTS[@]}"; do
mount_path=$(realpath "$mount_path") mount_path=$(realpath "$mount_path")
name=$(basename "$mount_path") name=$(basename "$mount_path")
tag="m_${name:0:29}"
QEMU_ARGS+=( QEMU_ARGS+=(
-virtfs "local,path=$mount_path,mount_tag=mount_$name,security_model=none,id=fs${FS_ID}" -virtfs "local,path=$mount_path,mount_tag=$tag,security_model=none,id=fs${FS_ID}"
) )
FS_ID=$((FS_ID + 1)) FS_ID=$((FS_ID + 1))
done done
if [ -n "$CLAUDE_DIR" ]; then if [ "$CLAUDE" = true ]; then
CLAUDE_DIR=$(realpath "$CLAUDE_DIR") if [ -z "${CLAUDE_CONFIG_DIR:-}" ]; then
QEMU_ARGS+=( echo "error: --claude requires CLAUDE_CONFIG_DIR to be set"
-virtfs "local,path=$CLAUDE_DIR,mount_tag=claude,security_model=none,id=fs${FS_ID}" exit 1
)
fi fi
mkdir -p "$CLAUDE_CONFIG_DIR"
claude_dir=$(realpath "$CLAUDE_CONFIG_DIR")
if [ -n "$CLAUDE_JSON" ]; then QEMU_ARGS+=(
QEMU_ARGS+=(-fw_cfg "name=opt/claude.json,file=$CLAUDE_JSON") -virtfs "local,path=$claude_dir,mount_tag=claude,security_model=none,id=fs${FS_ID}"
)
FS_ID=$((FS_ID + 1))
fi fi
exec "${QEMU_ARGS[@]}" exec "${QEMU_ARGS[@]}"