-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-Nixos.sh
More file actions
executable file
·61 lines (46 loc) · 2.49 KB
/
Install-Nixos.sh
File metadata and controls
executable file
·61 lines (46 loc) · 2.49 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
#!/usr/bin/env bash
main() {
clear
echo -e "Starting installation of Quezty's Nixos \n \n"
echo -e 'In order for the script to work, do the following steps before installing \n \n - Install git \n - add the line "nix.settings.experimental-features = [ "nix-command" "flakes" ];" to your existing config'
echo -e "\n \n \n"
# Runs grep on current configuration to later be used in if-statement that checks if necessary configuration is set up, sends error to stderr and displays echo message to fix issue. Then exits script
line=$(nix config show 2>/dev/null | grep "experimental-features" ) || {
echo 'Command "nix config show" failed, make sure you are running this on a system where nix is installed and the nix command is available!'
exit 0
}
# Quietly runs grep on the output of variable "line" to see if flakes and nix-command is enabled
if echo "$line" | grep -qw flakes && echo "$line" | grep -qw nix-command; then
echo "Experimental features enabled"
else
echo "Experimental features needed for the script to work was not enabled add the following lines to your configuration for the script to work"
echo -e '- nix.settings.experimental-features = [ "nix-command" "flakes" ]; \n \n'
exit 0
fi
# Attempts to run git -v to see if git is installed, probably cleaner way to do this
is_git_installed=$(git -v)
# Runs if statement on output of variable above. Needs improvement
if [[ -z "$is_git_installed" ]]; then
echo "git is not installed, install git and try again"
exit 0
else
echo "git is installed, downloading used repositories"
downloadRepositories
fi
# Creates directory where all the files will be stored for nixos configuration and dotfiles
if [ -d "$HOME/nixos" ]; then
echo "Directory exists"
else
echo "Creating directory to move configuration into"
mkdir ~/nixos
echo "nixos folder created in home directory of $USER"
fi
mv $PWD/tmp-files/* ~/nixos/
}
# Function to "cleanly" list all repositories that needs to be installed for the system to be complete, will probably remove this once I have landed on a better repository structure
downloadRepositories() {
git clone https://github.com/Quezty/NixosConfiguration.git tmp-files/NixosConfiguration
git clone https://github.com/Quezty/Justfile.git tmp-files/Justfile
git clone https://github.com/Quezty/HyprlandConf.git tmp-files/HyprlandConf
}
main "$@"