infra/nix/home-manager/profiles/dotfiles.nix

32 lines
811 B
Nix
Raw Normal View History

2018-11-04 14:52:52 +01:00
{ pkgs
, config
, ...
}:
let
repoHttps = "https://gitlab.com/steveeJ/dotfiles.git";
repoSsh = "git@gitlab.com:/steveeJ/dotfiles.git";
in {
home.activation.vcsh = config.lib.dag.entryAfter["linkGeneration"] ''
$DRY_RUN_CMD ${pkgs.writeScript "activation-script" ''
set -e
export HOST=$(hostname -s)
function set_remotes {
${pkgs.vcsh}/bin/vcsh dotfiles remote set-url origin ${repoHttps}
${pkgs.vcsh}/bin/vcsh dotfiles remote set-url --push origin ${repoSsh}
}
if ! test -d $HOME/.config/vcsh/repo.d/dotfiles.git; then
echo Cloning dotfiles for $HOST...
${pkgs.vcsh}/bin/vcsh clone -b $HOST ${repoHttps}
set_remotes
else
echo Updating dotfiles for $HOST...
set_remotes
${pkgs.vcsh}/bin/vcsh pull $HOST
fi
''};
'';
}