aboutsummaryrefslogtreecommitdiffstats
path: root/modules/home/dotfiles.nix
diff options
context:
space:
mode:
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}