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

43 lines
1.2 KiB
Nix
Raw Normal View History

2023-02-07 18:23:51 +01:00
{
pkgs,
repoHttps ? "https://gitlab.com/steveeJ/dotfiles.git",
repoSsh ? "git@gitlab.com:/steveeJ/dotfiles.git",
...
2024-11-15 10:17:56 +01:00
}:
let
2023-02-07 18:23:51 +01:00
repoBareLocal =
pkgs.runCommand "fetchbare"
2024-11-15 10:17:56 +01:00
{
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
)
'';
2023-02-07 18:23:51 +01:00
in
2024-11-15 10:17:56 +01:00
pkgs.writeScript "activation-script" ''
export HOST=$(hostname -s)
2024-11-15 10:17:56 +01:00
function set_remotes {
${pkgs.vcsh}/bin/vcsh dotfiles remote set-url origin $1
${pkgs.vcsh}/bin/vcsh dotfiles remote set-url --push origin $2
}
2024-11-15 10:17:56 +01:00
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
''