#! /bin/bash export NIXPKGS_ALLOW_UNFREE=1 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" elif [ "$(grep -Ei 'fedora' /etc/*release)" ]; then echo "Fedora" else echo 1 return 1 fi fi } d=$(detectDistro) if [[ $d == "Debian" ]]; then sudo apt install -y curl git elif [[ $d == "Arch" ]]; then sudo pacman -Sy curl git elif [[ $d == "Fedora" ]]; then sudo dnf install curl git fi if [ $(pwd) != "$HOME/dotfiles" ]; then cd $HOME git clone https://github.com/TrudeEH/dotfiles cd dotfiles fi if ! nix --version &>/dev/null; then echo -e "${YELLOW}[E] Nix not found.${ENDCOLOR}" echo -e "${GREEN}[+] Installing the Nix package manager...${ENDCOLOR}" curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh echo -e "${GREEN}[I] Installed Nix.${ENDCOLOR}" # echo # echo -e "${YELLOW}[I] A reboot is required for Nix to work correctly.${ENDCOLOR}" # echo -e "${GREEN}[I] Press ENTER to reboot.${ENDCOLOR}" # read # systemctl reboot fi # ============== HOME MANAGER ============== # Install nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --update nix-shell '' -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 home-manager -b backup switch echo echo -e "${GREEN}[I] Done. Rebooting in 5 seconds...${ENDCOLOR}" sleep 5 systemctl reboot