aboutsummaryrefslogtreecommitdiffstats
path: root/modules/home/dotfiles.nix
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2026-09-17 11:49:58 +0200
committerGravatar Tom van der Lee <tom@vanderlee.io>2026-09-17 11:49:58 +0200
commit41db5fc767fbe5a5453b2fa0583de8c3b2cf4021 (patch)
tree53c9f545c7e5bdbb57ec5e625edc54fb8da3d208 /modules/home/dotfiles.nix
parentf793f76e26b461c3228c69926d82bf950aaac671 (diff)
downloaddesktop-flake-41db5fc767fbe5a5453b2fa0583de8c3b2cf4021.tar.gz
desktop-flake-41db5fc767fbe5a5453b2fa0583de8c3b2cf4021.tar.bz2
desktop-flake-41db5fc767fbe5a5453b2fa0583de8c3b2cf4021.zip
Add automatic dotfiles clone + stow
modules/home/dotfiles.nix clones ~/dotfiles on activation (only if not already present) and stows every top-level package directory into $HOME, independently per package so one conflict doesn't block the rest. Removes home-manager's own git config management in favor of letting the stowed ~/dotfiles/git/.gitconfig own it, and adds homeConfigurations."tom@darwin" so the feature is usable on this Mac. users/tom.nix now points home.dotfiles.repoUrl at the real repo.
Diffstat (limited to 'modules/home/dotfiles.nix')
-rw-r--r--modules/home/dotfiles.nix32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/home/dotfiles.nix b/modules/home/dotfiles.nix
new file mode 100644
index 0000000..3df944c
--- /dev/null
+++ b/modules/home/dotfiles.nix
@@ -0,0 +1,32 @@
1{ config, lib, pkgs, ... }:
2let
3 cfg = config.home.dotfiles;
4 dotfilesDir = "${config.home.homeDirectory}/dotfiles";
5in
6{
7 options.home.dotfiles.repoUrl = lib.mkOption {
8 type = lib.types.str;
9 default = "";
10 description = "Git URL of the personal dotfiles repo to clone and stow into $HOME. Leave empty to disable.";
11 };
12
13 config = lib.mkIf (cfg.repoUrl != "") {
14 home.packages = [ pkgs.git pkgs.stow ];
15
16 home.activation.dotfiles = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
17 DOTFILES_DIR=${lib.escapeShellArg dotfilesDir}
18 if [ ! -d "$DOTFILES_DIR/.git" ]; then
19 $DRY_RUN_CMD ${pkgs.git}/bin/git clone --recurse-submodules \
20 ${lib.escapeShellArg cfg.repoUrl} "$DOTFILES_DIR"
21 fi
22 if [ -d "$DOTFILES_DIR" ]; then
23 for pkg in "$DOTFILES_DIR"/*/; do
24 pkg_name="$(basename "$pkg")"
25 case "$pkg_name" in .*) continue ;; esac
26 $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
28 done
29 fi
30 '';
31 };
32}