44 lines
1.5 KiB
Nix
44 lines
1.5 KiB
Nix
|
|
{ config, pkgs, lib, ... }:
|
||
|
|
|
||
|
|
{
|
||
|
|
home.activation.setupDotfiles = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||
|
|
DOTFILES_DIR="$HOME/.config/dotfiles"
|
||
|
|
|
||
|
|
if [ ! -d "$DOTFILES_DIR/.git" ]; then
|
||
|
|
if [[ -v DRY_RUN ]]; then
|
||
|
|
echo "Dry run: Would bootstrap dotfiles from labs.scarif.space"
|
||
|
|
else
|
||
|
|
echo "Dotfiles not found. Running bootstrap script..."
|
||
|
|
|
||
|
|
# Setup a temporary workspace
|
||
|
|
TEMP_DIR=$(mktemp -d)
|
||
|
|
|
||
|
|
# Clone the repo (using the public URL for the initial pull)
|
||
|
|
${pkgs.git}/bin/git clone -b main https://labs.scarif.space/chris/dotfiles.git "$TEMP_DIR"
|
||
|
|
|
||
|
|
# Copy files to HOME
|
||
|
|
${pkgs.coreutils}/bin/cp -rfT "$TEMP_DIR" "$HOME"
|
||
|
|
|
||
|
|
# Initialize the separate git directory
|
||
|
|
${pkgs.mkdirp}/bin/mkdir -p "$DOTFILES_DIR"
|
||
|
|
cd "$HOME"
|
||
|
|
${pkgs.git}/bin/git init --separate-git-dir "$DOTFILES_DIR/.git" "$HOME"
|
||
|
|
|
||
|
|
# Update submodules
|
||
|
|
${pkgs.git}/bin/git submodule set-url ".config/nvim" https://labs.scarif.space/chris/nvim.git
|
||
|
|
${pkgs.git}/bin/git submodule update --init
|
||
|
|
|
||
|
|
# Set URLs back to SSH
|
||
|
|
${pkgs.git}/bin/git submodule set-url ".config/nvim" git@labs.scarif.space:chris/nvim.git
|
||
|
|
${pkgs.git}/bin/git remote set-url origin git@labs.scarif.space:chris/dotfiles.git
|
||
|
|
|
||
|
|
# Clean up
|
||
|
|
${pkgs.coreutils}/bin/rm -rf "$TEMP_DIR"
|
||
|
|
${pkgs.coreutils}/bin/rm -f "$HOME/.git"
|
||
|
|
|
||
|
|
echo "Dotfiles bootstrapped successfully."
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
'';
|
||
|
|
}
|