dotfiles/vcsh: populate nix store with dotfiles mirror
This commit is contained in:
parent
a71fe67e78
commit
e7f6744be5
5 changed files with 49 additions and 22 deletions
|
@ -4,28 +4,10 @@
|
|||
}:
|
||||
|
||||
let
|
||||
repoHttps = "https://gitlab.com/steveeJ/dotfiles.git";
|
||||
repoSsh = "git@gitlab.com:/steveeJ/dotfiles.git";
|
||||
vcshActivationScript = pkgs.callPackage ./dotfiles/vcsh.nix {};
|
||||
|
||||
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
|
||||
''};
|
||||
$DRY_RUN_CMD ${vcshActivationScript}
|
||||
'';
|
||||
}
|
||||
|
|
1
nix/home-manager/profiles/dotfiles/.gitignore
vendored
Normal file
1
nix/home-manager/profiles/dotfiles/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
vcsh.nix
|
38
nix/home-manager/profiles/dotfiles/vcsh.tmpl.nix
Normal file
38
nix/home-manager/profiles/dotfiles/vcsh.tmpl.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{ pkgs
|
||||
, repoHttps ? "https://gitlab.com/steveeJ/dotfiles.git"
|
||||
, repoSsh ? "git@gitlab.com:/steveeJ/dotfiles.git"
|
||||
, ...
|
||||
}:
|
||||
|
||||
let
|
||||
repoHttps = "https://gitlab.com/steveeJ/dotfiles.git";
|
||||
repoSsh = "git@gitlab.com:/steveeJ/dotfiles.git";
|
||||
repoBareLocal = pkgs.runCommand "fetchbare" {
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = "0000000000000000000000000000000000000000000000000000";
|
||||
} ''
|
||||
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}
|
||||
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
|
||||
''
|
Loading…
Add table
Add a link
Reference in a new issue