forked from webpro/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
109 lines (81 loc) · 3.16 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
SHELL = /bin/bash -o pipefail
DOTFILES_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
OS := $(shell bin/is-supported bin/is-macos macos linux)
PATH := $(DOTFILES_DIR)bin:/opt/homebrew/bin:/usr/local/bin:$(PATH)
export XDG_CONFIG_HOME := $(HOME)/.config
export STOW_DIR := $(DOTFILES_DIR)
.PHONY: test
all: $(OS)
macos: sudo brew change-shell node ruby packages-macos link mackup
linux: sudo core-linux change-shell packages-linux link
core-linux:
sudo apt-get update
is-executable curl || sudo apt-get install -y curl
is-executable gcc || sudo apt-get install -y build-essential
is-executable git || sudo apt-get install -y git
is-executable locales || sudo apt-get install -y locales
sudo sh -c "echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen"
sudo locale-gen
stow-macos: brew
is-executable stow || brew install stow
stow-linux: core-linux
is-executable stow || sudo apt-get -y --no-install-recommends install stow
sudo:
ifndef CI
sudo -v
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
endif
packages-macos: ohmyzsh brew-packages node-packages gems python-packages
packages-linux: ohmyzsh
export FORCE=1; curl -fsSL https://starship.rs/install.sh | sh
link: stow-$(OS)
for FILE in $$(\ls -A runcom); do if [ -f $(HOME)/$$FILE -a ! -h $(HOME)/$$FILE ]; then mv -v $(HOME)/$$FILE{,.bak}; fi; done
mkdir -p $(XDG_CONFIG_HOME)
stow -t $(HOME) runcom
stow -t $(XDG_CONFIG_HOME) config
unlink: stow-$(OS)
stow --delete -t $(HOME) runcom
stow --delete -t $(XDG_CONFIG_HOME) config
for FILE in $$(\ls -A runcom); do if [ -f $(HOME)/$$FILE.bak ]; then mv -v $(HOME)/$$FILE.bak $(HOME)/$${FILE%%.bak}; fi; done
brew:
is-executable brew || curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash
zsh-macos: ZSH_BIN=/usr/local/bin/zsh
zsh-macos: SHELLS=/etc/shells
zsh-macos: brew
if ! grep -q $(ZSH_BIN) $(SHELLS); then brew install zsh && sudo append $(ZSH_BIN) $(SHELLS); fi
zsh-linux:
is-executable zsh || sudo apt-get install -y --no-install-recommends zsh
change-shell: zsh-$(OS)
ifndef CI
sudo chsh -s $$(which zsh)
endif
ohmyzsh: OH_MY_ZSH_HOME="$(XDG_CONFIG_HOME)/oh-my-zsh"
ohmyzsh:
test -d $(OH_MY_ZSH_HOME) || curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | ZSH=$(OH_MY_ZSH_HOME) sh
fnm: brew
is-executable fnm || (curl -fsSL https://fnm.vercel.app/install | bash)
node: fnm
rbenv: brew
is-executable rbenv || brew install rbenv
ruby: LATEST_RUBY=$(shell rbenv install -l | grep -v - | tail -1)
ruby: brew rbenv
ifndef CI
rbenv install -s $(LATEST_RUBY)
rbenv global $(LATEST_RUBY)
endif
brew-packages: brew
brew bundle --file=$(DOTFILES_DIR)/install/Brewfile
apps: brew
for EXT in $$(cat install/Codefile); do code --install-extension $$EXT; done
node-packages: node
npm install -g $(shell cat install/npmfile)
gems: ruby
export PATH=$(HOME)/.rbenv/shims:$(PATH); gem install -N $(shell cat install/Gemfile)
python-packages: brew
pip3 install -q $(shell cat install/pipfile)
mackup: link
# Necessary until [#632](https://github.com/lra/mackup/pull/632) is fixed
ln -s ~/.config/mackup/.mackup.cfg ~
ln -s ~/.config/mackup/.mackup ~
test:
bats test/*.bats