-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-nix.sh
187 lines (141 loc) Β· 4.35 KB
/
setup-nix.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
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
#!/bin/bash
###
# Configs
###
nix_pkgs=(
git
zsh
tmux
neovim
stow
fzf
eza
ripgrep
bat
direnv
dos2unix
unzip
meslo-lgs-nf
sqlite
lf # File manager
lazygit
lazydocker
oh-my-posh
# lldb # Debugger
delta # git pager
gopls
# krew
# skaffold
)
stow_dirs=(
common
git
lazygit
p10k
tmux
zsh
docker
)
echo "========================================================"
echo " π» System Wide Installation"
echo "========================================================"
# read -p "Installation for: (wsl | *linux): " sys
sys="linux"
[[ $(uname -r) == *"microsoft"* ]] && sys="wsl"
# Multi-user installation for Linux
nix_flag="--daemon"
# Change to Single-user installation for WSL
[ "$sys" == "wsl" ] && nix_flag="--no-daemon"
###
# Start installation
###
echo "π Generate locale language"
sudo locale-gen en.US-UTF-8
echo "=========================================="
echo "Installing Composer"
echo "=========================================="
# Using NIX will source NIX's php version
curl -sS https://getcomposer.org/installer | php && sudo mv composer.phar /usr/local/bin/composer
echo "=========================================="
echo "Installing antidote"
echo "=========================================="
git clone --depth=1 https://github.com/mattmc3/antidote.git "${ZDOTDIR:-~}/.antidote"
echo "=========================================="
echo "π¦ Installing NIX"
echo "=========================================="
sh <(curl -L https://nixos.org/nix/install) "$nix_flag"
[ "$sys" == "wsl" ] && . "$HOME/.nix-profile/etc/profile.d/nix.sh"
[ "$sys" == "linux" ] && . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
# Enable System support nix shell loader in .zshrc file
[ "$sys" == "wsl" ] && sed -i "/# WSL Nix/{n;s/# //I}" ./zsh/.zshrc
[ "$sys" == "linux" ] && sed -i "/# Linux Nix/{n;s/# //I}" ./zsh/.zshrc
echo "=========================================="
echo "Installing packages using NIX"
echo "=========================================="
# Add unstable channel
nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable && nix-channel --update unstable
for package in "${nix_pkgs[@]}"; do
echo "π¦ Installing $package"
NIXPKGS_ALLOW_UNFREE=1 nix-env -iA "nixpkgs.$package"
done
echo "=========================================="
echo "π Stowing dot files"
echo "=========================================="
# Export C locale if env is linux
[ "$sys" == "linux" ] && export LC_ALL=C
# To fix perl locale warning
export LC_ALL=C
for dir in "${stow_dirs[@]}"; do
echo "Stowing $dir"
stow "$dir"
done
echo "=========================================="
echo "Caching fonts"
echo "=========================================="
fc-cache -rv
echo "=========================================="
echo "πΌοΈ Configuring zsh"
echo "=========================================="
# source .profile for nix-env that installed zsh
source "$HOME/.profile"
# Load the profile script with zsh
"$(which zsh)" ./install-profile.zsh
echo "=========================================="
echo "Configure SSH"
echo "=========================================="
sudo sed -i 's/#Port 22/Port 22/I' /etc/ssh/sshd_config
sudo sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/I' /etc/ssh/sshd_config
echo "=========================================="
echo "π System Service"
echo "=========================================="
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl enable ssh
sudo systemctl start ssh
# Clean unnecessary files by nix
nix-collect-garbage -d
echo "=========================================="
echo "π Desktop environment setup"
echo "=========================================="
function desktop_env() {
if [ "$sys" == "wsl" ]; then
return 0
fi
echo "Install python modules"
pip3 install fuzzywuzzy faker requests pint simpleeval parsedatetime
echo "Installing python modules"
stow ulauncher
mkdir -p ~/.config/ulauncher/user-themes
git clone https://github.com/SylEleuth/ulauncher-gruvbox ~/.config/ulauncher/user-themes/gruvbox-ulauncher
# Fix docker permission
sudo chmod 666 /var/run/docker.sock
}
bat <<MANUAL_TASKS
==============================================
Remaining Manual Tasks....
==============================================
- Change root password, if you want to:
sudo passwd root
- Configure p10k style:
p10k configure
MANUAL_TASKS