From c90cc9427c556cf7439448e0d355c90ef9cc32cb Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Sun, 10 Aug 2025 13:25:22 -0700 Subject: [PATCH] Add matugen directory to backup handling - Add matugen to writable-mode backup script directory list - Add matugen conflict handling to Home Manager activation script - Handle both symlinked and regular matugen directories - Prevents activation failures due to existing matugen configs This resolves the 'mkdir: cannot create directory' and 'ln: failed to create symbolic link' errors that occur when ~/.config/matugen already exists during Home Manager activation. --- modules/home-manager.nix | 10 ++++++++++ modules/writable-mode.nix | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/home-manager.nix b/modules/home-manager.nix index bc3d819..3c4204c 100644 --- a/modules/home-manager.nix +++ b/modules/home-manager.nix @@ -195,6 +195,11 @@ EOF $DRY_RUN_CMD echo " → Removed conflicting symlinked fish config" fi + if [[ -L "$HOME/.config/matugen" ]]; then + $DRY_RUN_CMD rm "$HOME/.config/matugen" + $DRY_RUN_CMD echo " → Removed conflicting symlinked matugen config" + fi + # Also handle if they exist as regular directories if [[ -d "$HOME/.local/share/konsole" && ! -L "$HOME/.local/share/konsole" ]]; then $DRY_RUN_CMD mv "$HOME/.local/share/konsole" "$HOME/.local/share/konsole.backup-$(date +%Y%m%d-%H%M%S)" @@ -205,6 +210,11 @@ EOF $DRY_RUN_CMD mv "$HOME/.config/fish" "$HOME/.config/fish.backup-$(date +%Y%m%d-%H%M%S)" $DRY_RUN_CMD echo " → Backed up existing fish config directory" fi + + if [[ -d "$HOME/.config/matugen" && ! -L "$HOME/.config/matugen" ]]; then + $DRY_RUN_CMD mv "$HOME/.config/matugen" "$HOME/.config/matugen.backup-$(date +%Y%m%d-%H%M%S)" + $DRY_RUN_CMD echo " → Backed up existing matugen config directory" + fi ''; # Copy quickshell config after link generation diff --git a/modules/writable-mode.nix b/modules/writable-mode.nix index 128ac8b..d472e0b 100644 --- a/modules/writable-mode.nix +++ b/modules/writable-mode.nix @@ -58,7 +58,7 @@ let mkdir -p "$BACKUP_DIR" # Backup specific directories that will be overwritten - for dir in quickshell hypr fish foot kitty fuzzel wlogout; do + for dir in quickshell hypr fish foot kitty fuzzel wlogout matugen; do if [[ -d "$CONFIG_DIR/$dir" ]]; then info " Backing up $dir" cp -r "$CONFIG_DIR/$dir" "$BACKUP_DIR/" 2>/dev/null || true