-
Notifications
You must be signed in to change notification settings - Fork 44
/
install.sh
executable file
·132 lines (109 loc) · 3.68 KB
/
install.sh
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
#!/usr/bin/env bash
init() {
# Vars
CURRENT_USERNAME='frostphoenix'
# Colors
NORMAL=$(tput sgr0)
WHITE=$(tput setaf 7)
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
BRIGHT=$(tput bold)
UNDERLINE=$(tput smul)
}
confirm() {
echo -en "[${GREEN}y${NORMAL}/${RED}n${NORMAL}]: "
read -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 0
fi
}
print_header() {
echo -E "$CYAN
_____ _ ____ _ _
| ___| __ ___ ___| |_| _ \| |__ ___ ___ _ __ (_)_ __
| |_ | '__/ _ \/ __| __| |_) | '_ \ / _ \ / _ \ '_ \| \ \/ /
| _|| | | (_) \__ \ |_| __/| | | | (_) | __/ | | | |> <
|_| |_| \___/|___/\__|_| |_| |_|\___/ \___|_| |_|_/_/\_\
_ _ _ ___ ___ _ _ _
| \ | (_)_ __/ _ \ ___ |_ _|_ __ ___| |_ __ _| | | ___ _ __
| \| | \ \/ / | | / __| | || '_ \/ __| __/ _' | | |/ _ \ '__|
| |\ | |> <| |_| \__ \ | || | | \__ \ || (_| | | | __/ |
|_| \_|_/_/\_\\\\___/|___/ |___|_| |_|___/\__\__,_|_|_|\___|_|
$BLUE https://github.com/Frost-Phoenix $RED
! To make sure everything runs correctly DONT run as root ! $GREEN
-> '"./install.sh"' $NORMAL
"
}
get_username() {
echo -en "Enter your$GREEN username$NORMAL : $YELLOW"
read username
echo -en "$NORMAL"
echo -en "Use$YELLOW "$username"$NORMAL as ${GREEN}username${NORMAL} ? "
confirm
}
set_username() {
sed -i -e "s/${CURRENT_USERNAME}/${username}/g" ./flake.nix
sed -i -e "s/${CURRENT_USERNAME}/${username}/g" ./modules/home/audacious.nix
}
get_host() {
echo -en "Choose a ${GREEN}host${NORMAL} - [${YELLOW}D${NORMAL}]esktop, [${YELLOW}L${NORMAL}]aptop or [${YELLOW}V${NORMAL}]irtual machine: "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Dd]$ ]]; then
HOST='desktop'
elif [[ $REPLY =~ ^[Ll]$ ]]; then
HOST='laptop'
elif [[ $REPLY =~ ^[Vv]$ ]]; then
HOST='vm'
else
echo "Invalid choice. Please select 'D' for desktop, 'L' for laptop or 'V' for virtual machine."
exit 1
fi
echo -en "$NORMAL"
echo -en "Use the$YELLOW "$HOST"$NORMAL ${GREEN}host${NORMAL} ? "
confirm
}
install() {
echo -e "\n${RED}START INSTALL PHASE${NORMAL}\n"
sleep 0.2
# Create basic directories
echo -e "Creating folders:"
echo -e " - ${MAGENTA}~/Music${NORMAL}"
echo -e " - ${MAGENTA}~/Documents${NORMAL}"
echo -e " - ${MAGENTA}~/Pictures/wallpapers/others${NORMAL}"
mkdir -p ~/Music
mkdir -p ~/Documents
mkdir -p ~/Pictures/wallpapers/others
sleep 0.2
# Copy the wallpapers
echo -e "Copying all ${MAGENTA}wallpapers${NORMAL}"
cp -r wallpapers/wallpaper.png ~/Pictures/wallpapers
cp -r wallpapers/otherWallpaper/gruvbox/* ~/Pictures/wallpapers/others/
cp -r wallpapers/otherWallpaper/nixos/* ~/Pictures/wallpapers/others/
sleep 0.2
# Get the hardware configuration
echo -e "Copying ${MAGENTA}/etc/nixos/hardware-configuration.nix${NORMAL} to ${MAGENTA}./hosts/${HOST}/${NORMAL}\n"
cp /etc/nixos/hardware-configuration.nix hosts/${HOST}/hardware-configuration.nix
sleep 0.2
# Last Confirmation
echo -en "You are about to start the system build, do you want to process ? "
confirm
# Build the system (flakes + home manager)
echo -e "\nBuilding the system...\n"
sudo nixos-rebuild switch --flake .#${HOST}
}
main() {
init
print_header
get_username
set_username
get_host
install
}
main && exit 0