updates setup to run commands tested on clear nixos

This commit is contained in:
Menno van Leeuwen 2024-11-01 23:56:59 +01:00
parent bd127b3227
commit e3657a00b7
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Check if nixos-version is available
if [ -x "$(command -v nixos-version)" ]; then
@ -9,24 +9,39 @@ else
sh <(curl -L https://nixos.org/nix/install) --daemon
fi
# Check if sed is available
if [ ! -x "$(command -v sed)" ]; then
echo "sed is not available, please manually source the following lines in your .bashrc:"
echo "export PATH=$PATH:$HOME/.local/bin"
echo "export PATH=$PATH:~/dotfiles/bin"
return
# Check if home-manager is available
if [ -x "$(command -v home-manager)" ]; then
echo "Detected Home Manager, did you setup everything already!?"
echo "You should only run ./setup.sh once, re-running this could do damage."
exit 0
fi
if [ ! -f ~/.bashrc ]; then
touch ~/.bashrc
fi
# Link .bashrc
rm -rf $HOME/.bashrc
ln -s $HOME/dotfiles/.bashrc $HOME/.bashrc
sed -i -e '$a\'$'\n''export PATH=$PATH:$HOME/.local/bin' ~/.bashrc
sed -i -e '$a\'$'\n''export PATH=$PATH:~/dotfiles/bin' ~/.bashrc
# Install home-manager
sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz home-manager
sudo nix-channel --update
sudo nix-shell '<home-manager>' -A install
nix-shell '<home-manager>' -A install
echo "#########################################################"
# Link proper home-manager configs
rm -rf ~/.config/home-manager
ln -s $HOME/dotfiles/config/home-manager ~/.config/home-manager
# Link proper nixos configs
sudo ln -s $HOME/dotfiles/config/nixos/configuration.nix /etc/nixos/configuration.nix
# Rebuild NixOS
sudo nixos-rebuild switch
# Rebuild Home Manager
cd $HOME/dotfiles/config/home-manager && NIXPKGS_ALLOW_UNFREE=1 home-manager switch
echo "##############################################################"
echo "# #"
echo "# !!! RESTART YOUR TERMINAL BEFORE YOU CONTINUE !!! #"
echo "# !!! LOGOUT & LOGIN OR RESTART BEFORE YOU CONTINUE !!! #"
echo "# !!! Continue with 'dotf update' !!! #"
echo "# #"
echo "#########################################################"
echo "##############################################################"