39 lines
1.2 KiB
Nix
39 lines
1.2 KiB
Nix
{
|
|
pkgs,
|
|
repoHttps ? "https://gitlab.com/steveeJ/dotfiles.git",
|
|
repoSsh ? "git@gitlab.com:/steveeJ/dotfiles.git",
|
|
...
|
|
}: let
|
|
repoBareLocal =
|
|
pkgs.runCommand "fetchbare" {
|
|
outputHashMode = "recursive";
|
|
outputHashAlgo = "sha256";
|
|
outputHash = "0000000000000000000000000000000000000000000000000000";
|
|
} ''
|
|
(
|
|
set -xe
|
|
export GIT_SSL_CAINFO=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
|
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
|
${pkgs.git}/bin/git clone --mirror ${repoHttps} $out
|
|
)
|
|
'';
|
|
in
|
|
pkgs.writeScript "activation-script" ''
|
|
export HOST=$(hostname -s)
|
|
|
|
function set_remotes {
|
|
${pkgs.vcsh}/bin/vcsh dotfiles remote set-url origin $1
|
|
${pkgs.vcsh}/bin/vcsh dotfiles remote set-url --push origin $2
|
|
}
|
|
|
|
if ! test -d $HOME/.config/vcsh/repo.d/dotfiles.git; then
|
|
echo Cloning dotfiles for $HOST...
|
|
${pkgs.vcsh}/bin/vcsh clone -b $HOST ${repoBareLocal} dotfiles
|
|
set_remotes ${repoHttps} ${repoSsh}
|
|
else
|
|
set_remotes ${repoBareLocal} ${repoSsh}
|
|
echo Updating dotfiles for $HOST...
|
|
${pkgs.vcsh}/bin/vcsh pull $HOST || true
|
|
set_remotes ${repoHttps} ${repoSsh}
|
|
fi
|
|
''
|