34 lines
896 B
Nix
Raw Normal View History

2024-04-20 09:42:06 -04:00
{
config,
pkgs,
lib,
...
}:
{
2022-05-30 16:07:43 -04:00
2023-07-30 20:26:23 -04:00
# Allows me to make sure I can work on my dotfiles locally
2022-12-21 14:18:03 -07:00
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
2022-05-30 16:07:43 -04:00
2022-12-21 14:18:03 -07:00
config = lib.mkIf config.dotfiles.enable {
2022-05-30 16:07:43 -04:00
2022-12-21 14:18:03 -07:00
home-manager.users.${config.user} = {
2022-05-30 16:07:43 -04:00
2022-12-21 14:18:03 -07:00
home.activation = {
# Always clone dotfiles repository if it doesn't exist
2024-04-20 09:42:06 -04:00
cloneDotfiles = config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -d "${config.dotfilesPath}" ]; then
$DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}")
$DRY_RUN_CMD ${pkgs.git}/bin/git \
clone ${config.dotfilesRepo} "${config.dotfilesPath}"
fi
'';
2022-12-21 14:18:03 -07:00
};
2022-05-30 16:07:43 -04:00
2022-12-21 14:18:03 -07:00
# Set a variable for dotfiles repo, not necessary but convenient
home.sessionVariables.DOTS = config.dotfilesPath;
};
2022-05-30 16:07:43 -04:00
};
}