feat(dev): deploy claude-code config via systemd instead of home-manager
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.
This commit is contained in:
parent
4648d6b51a
commit
248534bc35
7 changed files with 114 additions and 1 deletions
35
utils/home-manager/claude-code/nixos.nix
Normal file
35
utils/home-manager/claude-code/nixos.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{ 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;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue