-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbootstrap.sh
168 lines (142 loc) Β· 5.58 KB
/
bootstrap.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
#!/usr/bin/env sh
###
### Variables
###
DOTFILES_REPO="https://github.com/biosan/dotfiles"
DOTFILES_PATH="${HOME}/.config/nixpkgs"
#
# Select Nix/Home-Manager modules to "install"
# Complete list:
# - common -- basic stuff, CLI utilis for a basic server machine
# - coding -- programming runtimes, compilers, package managers & tools (for Python, JS/TS, Rust, Go & Java)
# - gui -- cross-platform GUI apps (alacritty, etc.)
# - linux -- Linux spefic apps and configs
# - macos -- macOS spefic apps and configs
#
# Pre-configured machines setups
#SERVER="common"
#DOCKER="common coding"
#DESKTOP="common coding gui linux"
#MACBOOK="common coding gui macos"
#
# Actual modules to be installed
#NIX_SETUP="${MACBOOK}"
#
#
# /$$ /$$ /$$ /$$ /$$
# | $$ /$$/ | $$ | $$| $$
# \ $$ /$$/ /$$$$$$ /$$ /$$ /$$$$$$$| $$$$$$$ /$$$$$$ | $$| $$
# \ $$$$/ /$$__ $$| $$ | $$ /$$_____/| $$__ $$ |____ $$| $$| $$
# \ $$/ | $$ \ $$| $$ | $$ | $$$$$$ | $$ \ $$ /$$$$$$$| $$| $$
# | $$ | $$ | $$| $$ | $$ \____ $$| $$ | $$ /$$__ $$| $$| $$
# | $$ | $$$$$$/| $$$$$$/ /$$$$$$$/| $$ | $$| $$$$$$$| $$| $$
# |__/ \______/ \______/ |_______/ |__/ |__/ \_______/|__/|__/
#
#
#
# /$$
# | $$
# /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$$
# | $$__ $$ /$$__ $$|_ $$_/ /$$__ $$ |____ $$ /$$_____/ /$$_____/
# | $$ \ $$| $$ \ $$ | $$ | $$ \ $$ /$$$$$$$| $$$$$$ | $$$$$$
# | $$ | $$| $$ | $$ | $$ /$$ | $$ | $$ /$$__ $$ \____ $$ \____ $$
# | $$ | $$| $$$$$$/ | $$$$/ | $$$$$$$/| $$$$$$$ /$$$$$$$/ /$$$$$$$/
# |__/ |__/ \______/ \___/ | $$____/ \_______/|_______/ |_______/
# | $$
# | $$
# |__/
#
#
# ....
# .'' .'''
# . .' :
# \\ .: :
# \\ _: : ..----.._
# \\ .:::.....:::.. .' ''.
# \\ .' #-. .-######' # '.
# \\ '.##'/ ' ################ :
# \\ ##################### :
# \\ ..##.-.#### .''''###'.._ :
# \\ :--:########: '. .' :
# \\..__...--.. :--:#######.' '. '. :
# : : : : '':'-:'':':: . '. .'
# '---'''..: : ': '..'''. '. :'
# \\ :: : : ' ''''''. '. .:
# \\ :: : : ' '. ' :
# \\:: : : ....' ..: ' '.
# \\:: : : .....####\\ .~~.:. :
# \\':.:.:.:'#########.===. ~ |.'-. . '''.. :
# \\ .' ########## \ \ _.' '. '-. '''.
# :\\ : ######## \ \ '. '-. :
# : \\' ' #### : \ \ :. '-. :
# : .'\\ :' : : \ \ : '-. :
# : .' .\\ ' : : :\ \ : '. :
# :: : \\' :. : : \ \ : '. :
# ::. : \\ : : : ; \ \ : '.:
# : ': '\\ : : : : \:\ : ..'
# : ' \\ : : ; \| : .'''
# '. ' \\: :.''
# .:..... \\: : ..''
# '._____|'.\\......'''''''.:..'''
#
#
###
### Check if OS is macOS
###
if [[ "$(uname)" == "Darwin" ]]; then
IS_MAC='yes';
else
IS_MAC='';
fi
# Print current step function
print_step() {
GREEN='\033[0;32m'
RESET='\033[0m' # No Color
printf "\n${GREEN}>>> ${1}${RESET}\n\n"
}
###
### Nix common stuff
###
### Install Nix
print_step "Install Nix"
if [ IS_MAC ] then;
# NOTE: Maybe use an encrypted volume on macOS...
sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
else
sh <(curl -L https://nixos.org/nix/install)
fi
### Add unstable channell
print_step "Add unstable channel"
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
nix-channel --update
### Install home-manager
print_step "Install home-manager"
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
nix-shell '<home-manager>' -A install
### Clone dotfiles repo
print_step "Clone dotfiles repo"
rm -r "${DOTFILES_PATH}"
git clone "${DOTFILES_REPO}" "${DOTFILES_PATH}"
### Install home-manager config
print_step "Install home-manager config"
home-manager switch
###
### macOS specific stuff
###
if [ IS_MAC ]; then
### Install Homebrew
print_step "Hey this is a Mac... let's install Homebrew"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)";
### Install stuff from Homebrew
print_step "Install apps from Homebrew"
brew bundle --file "${DOTFILES_PATH}/config";
### Configure macOS
print_step "Configure your Mac"
sh ".${DOTFILES_PATH}/config/configure.macos.sh";
fi
################
### Restart! ###
################
print_step "Everything is setted up, now restart and enjoy your new machine!"