Problem
The home.activation.spacemacs script in home/default.nix fails on a fresh NixOS install in two ways:
1. Non-empty .emacs.d directory
Emacs auto-creates ~/.emacs.d/ (with eln-cache/, auto-save-list/, etc.) before the Home Manager activation runs. The activation script checks for ~/.emacs.d/.git but not for the directory itself, so git clone fails:
Activating spacemacs
fatal: destination path '/home/cwage/.emacs.d' already exists and is not an empty directory.
This causes exit code 128, which fails the entire Home Manager activation.
2. Systemd timeout on clone
Even when .emacs.d is clean, the Spacemacs repo clone can exceed the home-manager-cwage.service timeout (TimeoutStartSec=5m), causing systemd to SIGTERM the activation:
Mar 18 16:06:46 thinkpad hm-activate-cwage[8325]: Cloning into '/home/cwage/.emacs.d'...
Mar 18 16:11:46 thinkpad systemd[1]: home-manager-cwage.service: start operation timed out. Terminating.
Logs
Full journal from the session showing both failures:
# First boot — failed because .emacs.d existed (emacs auto-created it)
Mar 18 15:51:49 hm-activate-cwage[766]: Activating spacemacs
Mar 18 15:51:49 hm-activate-cwage[1066]: fatal: destination path '/home/cwage/.emacs.d' already exists and is not an empty directory.
Mar 18 15:51:49 systemd[1]: home-manager-cwage.service: Failed with result 'exit-code'.
# Second attempt after `rm -rf ~/.emacs.d` — clone started but hit 5min timeout
Mar 18 16:06:46 hm-activate-cwage[8089]: Activating spacemacs
Mar 18 16:06:46 hm-activate-cwage[8325]: Cloning into '/home/cwage/.emacs.d'...
Mar 18 16:11:46 systemd[1]: home-manager-cwage.service: start operation timed out. Terminating.
Mar 18 16:11:46 systemd[1]: home-manager-cwage.service: Failed with result 'timeout'.
Current code
home.activation.spacemacs = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -d "$HOME/.emacs.d/.git" ]; then
run ${pkgs.git}/bin/git clone --branch develop https://github.com/syl20bnr/spacemacs.git "$HOME/.emacs.d"
fi
'';
Proposed fix
home.activation.spacemacs = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -d "$HOME/.emacs.d/.git" ]; then
run rm -rf "$HOME/.emacs.d"
run ${pkgs.git}/bin/git clone --depth 1 --branch develop https://github.com/syl20bnr/spacemacs.git "$HOME/.emacs.d"
fi
'';
rm -rf handles the non-empty directory (safe since we confirmed no .git exists)
--depth 1 makes the clone much faster, avoiding the timeout (full Spacemacs history isn't needed)
Problem
The
home.activation.spacemacsscript inhome/default.nixfails on a fresh NixOS install in two ways:1. Non-empty
.emacs.ddirectoryEmacs auto-creates
~/.emacs.d/(witheln-cache/,auto-save-list/, etc.) before the Home Manager activation runs. The activation script checks for~/.emacs.d/.gitbut not for the directory itself, sogit clonefails:This causes exit code 128, which fails the entire Home Manager activation.
2. Systemd timeout on clone
Even when
.emacs.dis clean, the Spacemacs repo clone can exceed thehome-manager-cwage.servicetimeout (TimeoutStartSec=5m), causing systemd to SIGTERM the activation:Logs
Full journal from the session showing both failures:
Current code
Proposed fix
rm -rfhandles the non-empty directory (safe since we confirmed no.gitexists)--depth 1makes the clone much faster, avoiding the timeout (full Spacemacs history isn't needed)