78 lines
3.0 KiB
Nix
78 lines
3.0 KiB
Nix
{ lib, pkgs, ... }:
|
|
|
|
{
|
|
home.activation = {
|
|
setupDotfiles = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
|
if [[ -v DRY_RUN ]]; then
|
|
echo "Dry run: Would bootstrap dotfiles from labs.scarif.space"
|
|
exit
|
|
fi
|
|
|
|
TEMP_DIR=$(mktemp -d)
|
|
|
|
DOTFILES_DIR="$HOME/.config/dotfiles"
|
|
DOTFILES_GIT_DIR="$DOTFILES_DIR/.git"
|
|
|
|
if [ ! -d "$DOTFILES_GIT_DIR" ]; then
|
|
echo "No local repository so cloning from remote"
|
|
SOURCE="https://labs.scarif.space/chris/dotfiles.git"
|
|
${pkgs.git}/bin/git clone -b main "$SOURCE" "$TEMP_DIR"
|
|
mv "$TEMP_DIR/.git" "$DOTFILES_GIT_DIR"
|
|
else
|
|
echo "Local repository found so cloning from there"
|
|
${pkgs.git}/bin/git clone -b main "$DOTFILES_GIT_DIR" "$TEMP_DIR"
|
|
${pkgs.git}/bin/git --git-dir="$DOTFILES_GIT_DIR" --work-tree="$TEMP_DIR" pull --rebase || true
|
|
fi
|
|
|
|
echo "Copying dot files to home"
|
|
${pkgs.coreutils}/bin/cp -rfT "$TEMP_DIR" "$HOME"
|
|
|
|
NVIM_DIR="$HOME/.config/nvim"
|
|
echo "Neovim config not initialised so initialising from remote"
|
|
${pkgs.git}/bin/git --git-dir="$DOTFILES_GIT_DIR" --work-tree="$HOME" submodule set-url ".config/nvim" https://labs.scarif.space/chris/nvim.git
|
|
${pkgs.git}/bin/git --git-dir="$DOTFILES_GIT_DIR" --work-tree="$HOME" submodule update --init || true
|
|
${pkgs.git}/bin/git --git-dir="$DOTFILES_GIT_DIR" --work-tree="$HOME" submodule set-url ".config/nvim" git@labs.scarif.space:chris/nvim.git
|
|
|
|
cd "$HOME"
|
|
|
|
echo "Cleanup"
|
|
${pkgs.coreutils}/bin/rm -rf "$TEMP_DIR"
|
|
${pkgs.coreutils}/bin/rm -rf "$HOME/.git" || true
|
|
|
|
echo "Dotfiles bootstrapped successfully."
|
|
'';
|
|
setupDevDirectories = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
|
if [[ -v DRY_RUN ]]; then
|
|
echo "Dry run: Would create dev directories"
|
|
exit
|
|
fi
|
|
|
|
echo "Creating development directories"
|
|
|
|
for dir in "DevOps" "FSharp" "JavaScript" "Scala" "Rust" "PHP" "Tutorials" "Sites" "MobileApps" "Tries"; do
|
|
if [ ! -d "$HOME/Code/$dir" ]; then
|
|
mkdir -p "$HOME/Code/$dir"
|
|
fi
|
|
done
|
|
'';
|
|
setupInitialConfigs = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
|
if [[ -v DRY_RUN ]]; then
|
|
echo "Dry run: Would copy initial config files"
|
|
exit
|
|
fi
|
|
|
|
DEST_FILE="$HOME/.config/Nextcloud/nextcloud.cfg"
|
|
|
|
if [ ! -f "$DEST_FILE" ]; then
|
|
cp "${../initial-configs/nextcloud.cfg}" "$DEST_FILE"
|
|
fi
|
|
|
|
DEST_FILE="$HOME/.config/sinew.in/Enpass.conf"
|
|
|
|
if [ ! -f "$DEST_FILE" ]; then
|
|
cp "${../initial-configs/Enpass.conf}" "$DEST_FILE"
|
|
fi
|
|
'';
|
|
};
|
|
}
|