dotfiles/modules/common/repositories/dotfiles.nix

37 lines
1.1 KiB
Nix
Raw Normal View History

2022-05-30 20:07:43 +00:00
{ config, pkgs, lib, ... }: {
2022-12-21 21:18:03 +00:00
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
2022-05-30 20:07:43 +00:00
2022-12-21 21:18:03 +00:00
config = lib.mkIf config.dotfiles.enable {
2022-05-30 20:07:43 +00:00
2022-12-21 21:18:03 +00:00
home-manager.users.${config.user} = {
2022-05-30 20:07:43 +00:00
2022-12-21 21:18:03 +00:00
home.activation = {
# Always clone dotfiles repository if it doesn't exist
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}")
# Force HTTPS because anonymous SSH doesn't work
GIT_CONFIG_COUNT=1 \
GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" \
GIT_CONFIG_VALUE_0="git@github.com:" \
$DRY_RUN_CMD \
${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}"
2022-12-21 21:18:03 +00:00
fi
'';
};
2022-05-30 20:07:43 +00:00
2022-12-21 21:18:03 +00:00
# Set a variable for dotfiles repo, not necessary but convenient
home.sessionVariables.DOTS = config.dotfilesPath;
};
2022-07-26 03:15:26 +00:00
2022-05-30 20:07:43 +00:00
};
}