dotfiles/modules/common/repositories/dotfiles.nix
Noah Masur ab6a339c34 try to force https for dotfiles clone
git seems to fail with ssh, at least to github
2023-02-25 11:30:41 -05:00

35 lines
979 B
Nix

{ config, pkgs, lib, ... }: {
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
config = lib.mkIf config.dotfiles.enable {
home-manager.users.${config.user} = {
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_KEY_0 = "url.https://github.com/.insteadOf";
$DRY_RUN_CMD ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}"
fi
'';
};
# Set a variable for dotfiles repo, not necessary but convenient
home.sessionVariables.DOTS = config.dotfilesPath;
};
};
}