Home-manager fails on the dev microVM because nix-env --set needs writable nix state dirs, but the microVM shares /nix/store read-only via virtiofs. Extract shared claude-code settings into settings.nix, add a NixOS module (nixos.nix) that deploys the same files via a systemd oneshot service with RequiresMountsFor to handle virtiofs mount ordering. The nb host continues using home-manager unchanged.
35 lines
1.6 KiB
Nix
35 lines
1.6 KiB
Nix
{ pkgs, ... }:
|
|
let
|
|
agentsDir = ./agents;
|
|
statuslineScript = ./statusline-command.sh;
|
|
settings = import ./settings.nix { homeDir = "/home/dominik"; };
|
|
settingsJson = pkgs.writeText "claude-settings-local.json" (builtins.toJSON settings);
|
|
|
|
deployScript = pkgs.writeShellScript "deploy-claude-code" ''
|
|
install -d -m 755 -o 1000 -g 100 /home/dominik/.claude
|
|
install -d -m 755 -o 1000 -g 100 /home/dominik/.claude/agents
|
|
install -m 644 -o 1000 -g 100 ${agentsDir}/devil-advocate.md /home/dominik/.claude/agents/
|
|
install -m 644 -o 1000 -g 100 ${agentsDir}/lint-fixer.md /home/dominik/.claude/agents/
|
|
install -m 644 -o 1000 -g 100 ${agentsDir}/secret-scanner.md /home/dominik/.claude/agents/
|
|
install -m 644 -o 1000 -g 100 ${agentsDir}/test-runner.md /home/dominik/.claude/agents/
|
|
install -m 755 -o 1000 -g 100 ${statuslineScript} /home/dominik/.claude/statusline-command.sh
|
|
install -m 644 -o 1000 -g 100 ${settingsJson} /home/dominik/.claude/settings.local.json
|
|
'';
|
|
in
|
|
{
|
|
# Deploy claude-code config files via a systemd service instead of home-manager.
|
|
# This avoids the nix-env --set call that fails on microVMs with read-only /nix/store.
|
|
systemd.services.claude-code-dominik = {
|
|
description = "Deploy Claude Code config for dominik";
|
|
wantedBy = [ "multi-user.target" ];
|
|
# Wait for /home to be mounted (virtiofs on microVMs)
|
|
unitConfig.RequiresMountsFor = "/home/dominik";
|
|
# Rerun on config changes during nixos-rebuild switch
|
|
restartTriggers = [ deployScript ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStart = deployScript;
|
|
};
|
|
};
|
|
}
|