-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·235 lines (203 loc) · 7.09 KB
/
install.sh
File metadata and controls
executable file
·235 lines (203 loc) · 7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/usr/bin/env bash
set -e
# Set some colors for output messages
OK="$(tput setaf 2)[OK]$(tput sgr0)"
ERROR="$(tput setaf 1)[ERROR]$(tput sgr0)"
NOTE="$(tput setaf 3)[NOTE]$(tput sgr0)"
WARN="$(tput setaf 5)[WARN]$(tput sgr0)"
CAT="$(tput setaf 6)[ACTION]$(tput sgr0)"
ORANGE=$(tput setaf 166)
YELLOW=$(tput setaf 3)
RESET=$(tput sgr0)
# NixOS
if [ -n "$(grep -i nixos </etc/os-release)" ]; then
echo "Verified this is NixOS."
echo "-----"
else
echo "$ERROR This is not NixOS or the distribution information is not available."
exit 1
fi
# git
if command -v git &>/dev/null; then
echo "$OK Git is installed, continuing with installation."
echo "-----"
else
echo "$ERROR Git is not installed. Please install Git and try again."
echo "Example: nix-shell -p git"
exit 1
fi
# Checking if running on a VM and enable in default config.nix
if hostnamectl | grep -q 'Chassis: vm'; then
echo "${NOTE} Your system is running on a VM. Enabling guest services.."
echo "${WARN} A Kind reminder to enable 3D acceleration.."
sed -i '/vm\.guest-services\.enable = false;/s/vm\.guest-services\.enable = false;/ vm.guest-services.enable = true;/' hosts/default/config.nix
fi
# Checking if system has nvidia gpu and enable in default config.nix
if command -v lspci >/dev/null 2>&1; then
# lspci is available, proceed with checking for Nvidia GPU
if lspci -k | grep -A 2 -E "(VGA|3D)" | grep -iq nvidia; then
echo "${NOTE} Nvidia GPU detected. Setting up for nvidia..."
sed -i '/drivers\.nvidia\.enable = false;/s/drivers\.nvidia\.enable = false;/ drivers.nvidia.enable = true;/' hosts/default/config.nix
fi
fi
echo "-----"
printf "\n%.0s" {1..1}
echo "$NOTE Default options are in brackets []"
echo "$NOTE Just press enter to select the default"
sleep 1
echo "-----"
# hostname
read -rp "$CAT Enter Your New Hostname: [ default ] " hostName
if [ -z "$hostName" ]; then
hostName="default"
fi
# Create directory for the new hostname, unless the default is selected
if [ "$hostName" != "default" ]; then
mkdir -p hosts/"$hostName"
cp hosts/default/*.nix hosts/"$hostName"
git add .
else
echo "Default hostname selected, no extra hosts directory created."
fi
echo "-----"
# keyboard layout
read -rp "$CAT Enter your keyboard layout: [ us ] " keyboardLayout
if [ -z "$keyboardLayout" ]; then
keyboardLayout="us"
fi
sed -i 's/keyboardLayout\s*=\s*"\([^"]*\)"/keyboardLayout = "'"$keyboardLayout"'"/' ./hosts/$hostName/variables.nix
echo "-----"
# username
installusername=$(echo $USER)
sed -i 's/username\s*=\s*"\([^"]*\)"/username = "'"$installusername"'"/' ./flake.nix
# hardware(3times)
echo "$NOTE Generating The Hardware Configuration"
attempts=0
max_attempts=3
hardware_file="./hosts/$hostName/hardware.nix"
while [ $attempts -lt $max_attempts ]; do
sudo nixos-generate-config --show-hardware-config >"$hardware_file" 2>/dev/null
if [ -f "$hardware_file" ]; then
echo "${OK} Hardware configuration successfully generated."
break
else
echo "${WARN} Failed to generate hardware configuration. Attempt $((attempts + 1)) of $max_attempts."
attempts=$((attempts + 1))
# Exit if this was the last attempt
if [ $attempts -eq $max_attempts ]; then
echo "${ERROR} Unable to generate hardware configuration after $max_attempts attempts."
exit 1
fi
fi
done
echo "-----"
# git config
echo "$NOTE Setting Required Nix Settings Then Going To Install"
git config --global user.name "installer"
git config --global user.email "installer@gmail.com"
git add .
sed -i 's/host\s*=\s*"\([^"]*\)"/host = "'"$hostName"'"/' ./flake.nix
printf "\n%.0s" {1..2}
echo "$NOTE Rebuilding NixOS..... so pls be patient.."
echo "-----"
echo "$CAT In the meantime, go grab a coffee or stretch or something..."
echo "-----"
echo "$ERROR YES!!! YOU read it right.. you staring too much at your monitor ha ha... joke :)......"
printf "\n%.0s" {1..2}
# Set the Nix configuration for experimental features
NIX_CONFIG="experimental-features = nix-command flakes"
#sudo nix flake update
sudo nixos-rebuild switch --flake ~/loneros-nixos/#"${hostName}"
echo "-----"
printf "\n%.0s" {1..2}
# GTK Themes and Icons installation
printf "Installing Themes and Icons..\n"
if [ -d "GTK-themes-icons" ]; then
echo "$NOTE GTK themes and Icons folder exist..deleting..."
rm -rf "GTK-themes-icons"
fi
echo "$NOTE Cloning themes repository..."
if git clone --depth 1 https://github.com/lonerOrz/GTK-themes-icons.git; then
cd GTK-themes-icons
chmod +x auto-extract.sh
./auto-extract.sh
cd ..
echo "$OK Extracted GTK Themes & Icons to ~/.icons & ~/.themes folders"
else
echo "$ERROR Download failed for GTK themes and Icons.."
fi
echo "$OK Extracted Bibata-Modern-Ice.tar.xz to ~/.icons folder."
echo "-----"
printf "\n%.0s" {1..2}
# Setting gtk-3.0 Thunar xfce4 config
for DIR1 in gtk-3.0 Thunar xfce4; do
DIRPATH=~/.config/$DIR1
if [ -d "$DIRPATH" ]; then
echo -e "${NOTE} Config for $DIR1 found, no need to copy."
else
echo -e "${NOTE} Config for $DIR1 not found, copying from assets."
cp -r assets/$DIR1 ~/.config/ && echo "Copy $DIR1 completed!" || echo "Error: Failed to copy $DIR1 config files."
fi
done
echo "-----"
printf "\n%.0s" {1..3}
# Cloning loneros-dots repo to home folder
printf "$NOTE Downloading loneros-dots to HOME folder..\n"
if [ -d ~/loneros-dots ]; then
cd ~/loneros-dots
# Check if upstream is already set
if ! git remote | grep -q "upstream"; then
echo -e "${INFO} - Adding upstream remote repository."
git remote add upstream https://github.com/JaKooLit/Hyprland-Dots.git
fi
git fetch upstream
#git merge upstream/main
echo -e "${INFO} - Rebasing local changes onto upstream/main."
git rebase upstream/main
# Stash and apply only if there are local changes
if ! git diff-index --quiet HEAD --; then
echo -e "${INFO} - Stashing local changes."
git stash
echo -e "${INFO} - Pulling latest changes."
git pull
echo -e "${INFO} - Applying stashed changes."
git stash apply
fi
chmod +x loneros.sh
./loneros.sh
else
if git clone --depth 1 https://github.com/lonerOrz/loneros-dots.git ~/loneros-dots; then
cd ~/loneros-dots || exit 1
chmod +x loneros.sh
./loneros.sh
else
echo -e "$ERROR Can't download loneros-dots"
fi
fi
#return to loneros-nixos
cd ~/loneros-nixos
# copy NixOS fastfetch config
echo "$NOTE Cloning fastfetch config ..."
cp -r assets/fastfetch ~/.config/ || true
echo "-----"
printf "\n%.0s" {1..2}
# Completed !
if command -v Hyprland &>/dev/null; then
printf "\n${OK} Yey! Installation Completed.${RESET}\n"
sleep 2
printf "\n${NOTE} You can start Hyprland by typing Hyprland (note the capital H!).${RESET}\n"
printf "\n${NOTE} It is highly recommended to reboot your system.${RESET}\n\n"
# Prompt user to reboot
read -rp "${CAT} Would you like to reboot now? (y/n): ${RESET}" HYP
if [[ $HYP =~ ^[Yy]$ ]]; then
# If user confirms, reboot the system
systemctl reboot
else
# Print a message if the user does not want to reboot
echo "Reboot skipped."
fi
else
# Print error message if Hyprland is not installed
printf "\n${WARN} Hyprland failed to install. Please check Install-Logs...${RESET}\n\n"
exit 1
fi