Switch to home-manager instead of managing dotfiles manually

This commit is contained in:
2024-03-27 13:35:01 +00:00
parent f5fe3fe9c3
commit 4e25f86c98
10 changed files with 246 additions and 144 deletions

View File

@@ -1,9 +1,20 @@
#! /bin/bash
source scripts/p.sh
source scripts/color.sh
# ============== CONFIG ==============
detectDistro() {
if [ "$(uname -s)" = "Darwin" ]; then
echo "macOS"
else
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
echo "Debian"
elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then
echo "Arch"
else
echo 1
return 1
fi
fi
return 0
}
d=$(detectDistro)
if [[ $d == "Debian" ]]; then
@@ -12,18 +23,28 @@ elif [[ $d == "Arch" ]]; then
sudo pacman -Sy curl
fi
echo -e "${GREEN}[+] Installing stow...${ENDCOLOR}"
p i stow
# Link dotfile home to $HOME
echo -e "${GREEN}[+] Symlinking dotfiles...${ENDCOLOR}"
stow -v -t $HOME home --adopt
git diff
git reset --hard
if ! nix --version &>/dev/null; then
echo -e "${YELLOW}[E] Nix not found.${ENDCOLOR}"
echo -e "${GREEN}[+] Installing the Nix package manager...${ENDCOLOR}"
curl -L https://nixos.org/nix/install | sh
. $HOME/.nix-profile/etc/profile.d/nix.sh
echo -e "${GREEN}[I] Installed Nix.${ENDCOLOR}"
fi
# Fix to add GUI nix-env apps to the GNOME launcher without having to restart
ln -s "$HOME/.nix-profile/share/applications" "$HOME/.local/share/applications/nix-env"
# ============== HOME MANAGER ==============
# Install font
nix-env -iA nixpkgs.fira-code-nerdfont
# Install
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
# Apply config
mkdir -p $HOME/.config/home-manager
rm $HOME/.config/home-manager/home.nix
ln -s $HOME/dotfiles/home.nix $HOME/.config/home-manager/home.nix
export NIXPKGS_ALLOW_UNFREE=1
home-manager switch -b backup