-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
216 lines (167 loc) · 7.29 KB
/
Makefile
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
SHELL := /usr/bin/env bash
LOGFILE := dotfiles.log
PACMAN_BUNDLE_FILE := Pacfile
AUR_BUNDLE_FILE := Aurfile
EXTRA_PKGS := 1
host := $(shell uname -s)
arch := $(shell uname -p)
ifeq ($(host),Darwin)
is_linux = 0
else
is_linux = 1
ifeq ($(command -v paru 2>),"/usr/local/bin/paru"))
paru_installed := $(shell command -v paru 2> /dev/null)
else
paru_installed = 0
endif
endif
ifeq ($(host),Darwin)
all: configure-osx | apply
else
all: configure-linux | apply
endif
configure-linux:
@echo "Updating pacman.conf.."
sudo sed -i '/Color$/s/^#//g' /etc/pacman.conf
sudo sed -i '/TotalDownload$/s/^#//g' /etc/pacman.conf
sudo sed -i '/CheckSpace$/s/^#//g' /etc/pacman.conf
sudo sed -i '/VerbosePkgLists$/s/^#//g' /etc/pacman.conf
sudo sed -i '/^#\[multilib\]/{N;s/#//g}' /etc/pacman.conf
@echo "Enable timedatectl and set up timezone"
sudo timedatectl set-timezone America/Sao_Paulo
sudo timedatectl set-ntp 1
sudo timedatectl set-local-rtc 0
sudo ln -sf /usr/share/zoneinfo/Ameriaca/Sao_Paulo /etc/localtime
@echo "Setup locale"
sudo sed -i '/en_US.UTF-8$/s/^#//g' /etc/pacman.conf
sudo locale-gen
@echo "Enable non-root access to dmesg"
sudo /sbin/sysctl kernel.dmesg_restrict=0
echo kernel.dmesg_restrict=0 | sudo tee -a /etc/sysctl.d/99-dmesg.conf
@echo "Updating geoclue.conf.."
redshift_line="\n[redshift]\nallowed=true\nsystem=false\nusers=\n"
grep -qF "[redshift]" "/etc/geoclue/geoclue.conf" || echo -e "$redshift_line" | sudo tee -a "/etc/geoclue/geoclue.conf"
@echo "Importing Spotify GPG key"
curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | gpg --import -
@echo "Importing Chaotic AUR"
sudo pacman-key --recv-key FBA220DFC880C036 --keyserver keyserver.ubuntu.com
sudo pacman-key --lsign-key FBA220DFC880C036
sudo pacman -U --noconfirm \
'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' \
'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
chaoticaur_lines="\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist"
grep -qF "[chaotic-aur]" "/etc/pacman.conf" \
|| echo -e "$chaoticaur_lines" | sudo tee -a "/etc/pacman.conf"
configure-osx:
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
@echo "Save to disk and not in iCloud by default"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
@echo "Quit printer app when jobs are completed"
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
@echo "Disable the “Are you sure you want to open this application?” dialog"
defaults write com.apple.LaunchServices LSQuarantine -bool false
@echo "Trackpad: enable tap to click for this user and for the login screen"
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
@echo "Increase sound quality for Bluetooth headphones/headsets"
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
@echo "Set a blazingly fast keyboard repeat rate"
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
@echo "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
@echo "Save screenshots to the desktop"
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
@echo "Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)"
defaults write com.apple.screencapture type -string "png"
@echo "Finder: show hidden files by default"
defaults write com.apple.finder AppleShowAllFiles -bool true
@echo "Finder: show all filename extensions"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
@echo "Avoid creating .DS_Store files on network or USB volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
@echo "Set to check daily instead of weekly"
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
@echo "Set default clock format"
defaults write com.apple.menuextra.clock DateFormat -string "EEE d MMM h:mm:ss a"
@echo "Set Default Finder Location to Home Folder"
defaults write com.apple.finder NewWindowTarget -string "PfLo"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"
killall Finder
killall SystemUIServer
@echo "build locate database"
sudo launchctl load -w /system/library/launchdaemons/com.apple.locate.plist || true
@echo "enable firewall"
sudo /usr/libexec/applicationfirewall/socketfilterfw --setglobalstate on
@echo "set clock using network time"
sudo systemsetup setusingnetworktime on
install-git-dependencies:
if [[ -f "$(HOME)/.vim/autoload/plug.vim" && -x `command -v nvim` ]]; then \
pip install neovim
nvim +PlugInstall +qall --headless; \
nvim +UpdateRemotePlugins +qall --headless; \
fi
if [[ ! -f "$(HOME)/.emacs.d/bin/doom" ]]; then \
git clone --depth 1 https://github.com/hlissner/doom-emacs "$(HOME)/.emacs.d"; \
"$(HOME)/.emacs.d/bin/doom" install -!; \
else \
"$(HOME)/.emacs.d/bin/doom" sync -e -!; \
fi
if [[ ! -f "usr/local/bin/notes" ]]; then \
curl -L https://raw.githubusercontent.com/pimterry/notes/latest-release/install.sh | sudo bash; \
fi
install-go-dependencies:
@echo "Installing gitmux.."
go install github.com/arl/gitmux@latest
@echo "Installing gopls.."
GO111MODULE=on go install golang.org/x/tools/gopls@latest
install-pyenv:
if [[ "$(host)" == "Darwin"* ]]; then \
LDFLAGS="-L/usr/local/opt/zlib/lib"; \
fi
if [ ! -d "$(HOME)/.pyenv" ]; then \
curl https://pyenv.run | bash; \
PATH="$(HOME)/.pyenv/bin:${PATH}"; \
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -s 3.10.2; \
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -s 3.8.12; \
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -s 3.9.9; \
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -s 3.11.0; \
fi
eval `pyenv init -)`
pip install --upgrade -r scripts/requirements.txt
install-extra-dependencies:
if [[ $(is_linux) -eq 1 ]]; then \
sudo pacman -Syyu; \
sudo pacman -S --noconfirm --needed - <"$(PACMAN_BUNDLE_FILE)"; \
if [ $(paru_installed) -eq 1 ]; then \
paru -S --noconfirm --nouseask --needed - <"$(AUR_BUNDLE_FILE)"; \
else \
git clone https://aur.archlinux.org/paru.git /tmp/paru; \
(cd /tmp/paru && makepkg -si --noconfirm --needed && rm -rf /tmp/paru); \
paru -S --noconfirm --nouseask --needed - <"$(AUR_BUNDLE_FILE)"; \
fi; \
else \
brew update; \
brew bundle; \
fi
install-required-dependencies:
if [[ $(is_linux) -eq 1 ]]; then \
sudo pacman -S chezmoi && paru -S 1password-cli; \
else \
brew install chezmoi 1password-cli; \
fi
fix-permissions:
@echo "Fixing GnuPG permissions"
chown -R $(USER) ~/.gnupg/
chmod 700 ~/.gnupg/*
chmod 700 ~/.gnupg
chmod 755 $(HOME)/.ssh
[ -f "$(HOME)/.ssh/id_ed25519" ] && chmod 600 "$(HOME)/.ssh/id_ed25519"
[ -f "$(HOME)/.ssh/id_ed25519.pub" ] && chmod 600 "$(HOME)/.ssh/id_ed25519.pub"
apply: install-required-dependencies
bw login || true
chezmoi apply -v
$(MAKE) fix-permissions