aboutsummaryrefslogtreecommitdiffstats
path: root/modules/home/dotfiles.nix
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2026-09-18 15:35:22 +0200
committerGravatar Tom van der Lee <tom@vanderlee.io>2026-09-18 15:35:22 +0200
commitd4437daf6fa0c0e8142ef51d16d5bf04d6cd15db (patch)
tree687a682a6de2f6d3e475c798ac8428ee7db85ad7 /modules/home/dotfiles.nix
parentb712f7c8a063e49329edf0db07d54a5174bfbd9b (diff)
downloaddesktop-flake-d4437daf6fa0c0e8142ef51d16d5bf04d6cd15db.tar.gz
desktop-flake-d4437daf6fa0c0e8142ef51d16d5bf04d6cd15db.tar.bz2
desktop-flake-d4437daf6fa0c0e8142ef51d16d5bf04d6cd15db.zip
Skip platform-irrelevant dotfiles packages during stow
iterm2 was being stowed on Linux and herbstluftwm/xorg on Darwin. Add a built-in Darwin/Linux exclude default plus an excludePackages override option in modules/home/dotfiles.nix, superseding the earlier "accept harmless unused symlinks" decision. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BBSd4VBfoKHjE1HR3P8kmn
Diffstat (limited to 'modules/home/dotfiles.nix')
-rw-r--r--modules/home/dotfiles.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/home/dotfiles.nix b/modules/home/dotfiles.nix
index 3df944c..21afb5e 100644
--- a/modules/home/dotfiles.nix
+++ b/modules/home/dotfiles.nix
@@ -2,6 +2,15 @@
2let 2let
3 cfg = config.home.dotfiles; 3 cfg = config.home.dotfiles;
4 dotfilesDir = "${config.home.homeDirectory}/dotfiles"; 4 dotfilesDir = "${config.home.homeDirectory}/dotfiles";
5
6 # Packages in the external dotfiles repo that are only relevant on one
7 # platform. Kept minimal and overridable via excludePackages rather than
8 # a full per-platform mapping - see design.md for alternatives considered.
9 platformDefaultExcludes =
10 lib.optionals (!pkgs.stdenv.isDarwin) [ "iterm2" ]
11 ++ lib.optionals (!pkgs.stdenv.isLinux) [ "herbstluftwm" "xorg" ];
12
13 excludePackages = platformDefaultExcludes ++ cfg.excludePackages;
5in 14in
6{ 15{
7 options.home.dotfiles.repoUrl = lib.mkOption { 16 options.home.dotfiles.repoUrl = lib.mkOption {
@@ -10,11 +19,18 @@ in
10 description = "Git URL of the personal dotfiles repo to clone and stow into $HOME. Leave empty to disable."; 19 description = "Git URL of the personal dotfiles repo to clone and stow into $HOME. Leave empty to disable.";
11 }; 20 };
12 21
22 options.home.dotfiles.excludePackages = lib.mkOption {
23 type = lib.types.listOf lib.types.str;
24 default = [ ];
25 description = "Names of dotfiles stow packages to always skip, in addition to built-in platform defaults.";
26 };
27
13 config = lib.mkIf (cfg.repoUrl != "") { 28 config = lib.mkIf (cfg.repoUrl != "") {
14 home.packages = [ pkgs.git pkgs.stow ]; 29 home.packages = [ pkgs.git pkgs.stow ];
15 30
16 home.activation.dotfiles = lib.hm.dag.entryAfter [ "writeBoundary" ] '' 31 home.activation.dotfiles = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
17 DOTFILES_DIR=${lib.escapeShellArg dotfilesDir} 32 DOTFILES_DIR=${lib.escapeShellArg dotfilesDir}
33 EXCLUDE_PACKAGES=(${lib.escapeShellArgs excludePackages})
18 if [ ! -d "$DOTFILES_DIR/.git" ]; then 34 if [ ! -d "$DOTFILES_DIR/.git" ]; then
19 $DRY_RUN_CMD ${pkgs.git}/bin/git clone --recurse-submodules \ 35 $DRY_RUN_CMD ${pkgs.git}/bin/git clone --recurse-submodules \
20 ${lib.escapeShellArg cfg.repoUrl} "$DOTFILES_DIR" 36 ${lib.escapeShellArg cfg.repoUrl} "$DOTFILES_DIR"
@@ -23,6 +39,17 @@ in
23 for pkg in "$DOTFILES_DIR"/*/; do 39 for pkg in "$DOTFILES_DIR"/*/; do
24 pkg_name="$(basename "$pkg")" 40 pkg_name="$(basename "$pkg")"
25 case "$pkg_name" in .*) continue ;; esac 41 case "$pkg_name" in .*) continue ;; esac
42 skip=false
43 for excluded in "''${EXCLUDE_PACKAGES[@]}"; do
44 if [ "$pkg_name" = "$excluded" ]; then
45 skip=true
46 break
47 fi
48 done
49 if [ "$skip" = true ]; then
50 echo "Skipping dotfiles package '$pkg_name' — not relevant on this platform." >&2
51 continue
52 fi
26 $DRY_RUN_CMD ${pkgs.stow}/bin/stow -d "$DOTFILES_DIR" -t ${lib.escapeShellArg config.home.homeDirectory} "$pkg_name" \ 53 $DRY_RUN_CMD ${pkgs.stow}/bin/stow -d "$DOTFILES_DIR" -t ${lib.escapeShellArg config.home.homeDirectory} "$pkg_name" \
27 || echo "Warning: stow failed for package '$pkg_name' — skipped." >&2 54 || echo "Warning: stow failed for package '$pkg_name' — skipped." >&2
28 done 55 done