Fix dotfiles script
This commit is contained in:
46
flake.nix
46
flake.nix
@@ -163,47 +163,45 @@
|
|||||||
"Downloads"
|
"Downloads"
|
||||||
"Tower"
|
"Tower"
|
||||||
".config/dotfiles"
|
".config/dotfiles"
|
||||||
|
".config/nvim"
|
||||||
".local/share/direnv"
|
".local/share/direnv"
|
||||||
".ssh"
|
".ssh"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
activation.setupDotfiles = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
activation.setupDotfiles = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
touch "$HOME/test.txt"
|
|
||||||
if [[ -v DRY_RUN ]]; then
|
if [[ -v DRY_RUN ]]; then
|
||||||
echo "Dry run: Would bootstrap dotfiles from labs.scarif.space"
|
echo "Dry run: Would bootstrap dotfiles from labs.scarif.space"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DOTFILES_DIR="$HOME/.config/dotfiles"
|
|
||||||
|
|
||||||
if [ -d "$DOTFILES_DIR/.git" ]; then
|
|
||||||
SOURCE="$DOTFILES_DIR/.git"
|
|
||||||
else
|
|
||||||
SOURCE="https://labs.scarif.space/chris/dotfiles.git"
|
|
||||||
|
|
||||||
# Initialize the separate git directory
|
|
||||||
if [ ! -d "$DOTFILES_DIR" ]; then
|
|
||||||
${pkgs.coreutils}/bin/mkdir -p "$DOTFILES_DIR"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
DOTFILES_DIR="$HOME/.config/dotfiles"
|
||||||
|
|
||||||
|
if [ ! -d "$DOTFILES_DIR/.git" ]; then
|
||||||
|
SOURCE="https://labs.scarif.space/chris/dotfiles.git"
|
||||||
${pkgs.git}/bin/git clone -b main "$SOURCE" "$TEMP_DIR"
|
${pkgs.git}/bin/git clone -b main "$SOURCE" "$TEMP_DIR"
|
||||||
|
mv "$TEMP_DIR/.git" "$DOTFILES_DIR/.git"
|
||||||
|
else
|
||||||
|
SOURCE="$DOTFILES_DIR/.git"
|
||||||
|
${pkgs.git}/bin/git clone -b main "$SOURCE" "$TEMP_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
${pkgs.coreutils}/bin/cp -rfT "$TEMP_DIR" "$HOME"
|
||||||
|
|
||||||
|
NVIM_DIR="$HOME/.config/nvim"
|
||||||
|
if [ ! -d "$NVIM_DIR/.git" ]; then
|
||||||
|
${pkgs.git}/bin/git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" submodule set-url ".config/nvim" https://labs.scarif.space/chris/nvim.git
|
||||||
|
${pkgs.git}/bin/git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" submodule update --init
|
||||||
|
${pkgs.git}/bin/git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" submodule set-url ".config/nvim" git@labs.scarif.space:chris/nvim.git
|
||||||
|
fi
|
||||||
|
|
||||||
${pkgs.coreutils}/bin/cp -rfT "$TEMP_DIR" "$HOME"
|
|
||||||
cd "$HOME"
|
cd "$HOME"
|
||||||
${pkgs.git}/bin/git init --separate-git-dir "$DOTFILES_DIR/.git" "$HOME"
|
|
||||||
|
|
||||||
${pkgs.git}/bin/git submodule set-url ".config/nvim" https://labs.scarif.space/chris/nvim.git
|
${pkgs.coreutils}/bin/rm -rf "$TEMP_DIR"
|
||||||
${pkgs.git}/bin/git submodule update --init
|
|
||||||
|
|
||||||
${pkgs.git}/bin/git submodule set-url ".config/nvim" git@labs.scarif.space:chris/nvim.git
|
# Add test file with timestamp
|
||||||
${pkgs.git}/bin/git remote set-url origin git@labs.scarif.space:chris/dotfiles.git
|
${pkgs.coreutils}/bin/touch "$HOME/.bootstrap-success-$(date +%s)"
|
||||||
|
|
||||||
# Clean up
|
|
||||||
${pkgs.coreutils}/bin/rm -rf "$TEMP_DIR"
|
|
||||||
${pkgs.coreutils}/bin/rm -f "$HOME/.git"
|
|
||||||
|
|
||||||
echo "Dotfiles bootstrapped successfully."
|
echo "Dotfiles bootstrapped successfully."
|
||||||
'';
|
'';
|
||||||
|
|||||||
Reference in New Issue
Block a user