Skip to content

Commit 64becc7

Browse files
committed
Switch to a yaml based install
1 parent 75f845f commit 64becc7

File tree

12 files changed

+633
-567
lines changed

12 files changed

+633
-567
lines changed

install.sh

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,46 @@
22

33
set -e
44

5+
DOTFILES=$(pwd)
6+
source "$DOTFILES/scripts/base_install.sh"
7+
58
# get the kernel string
69
kernel=$(uname -r)
710
case "$kernel" in
8-
*"android"* )
9-
./scripts/phone.sh
10-
;;
11-
*"azure"* ) # github action
12-
export CI=true
13-
if [[ $DEV_WORKSPACE != "" ]]; then
14-
./scripts/devcontainer.sh
15-
else
16-
./scripts/main.sh
17-
fi
18-
;;
19-
*"generic"* )
20-
if [[ $DEV_WORKSPACE != "" ]]; then
21-
./scripts/devcontainer.sh
22-
else
23-
./scripts/main.sh
24-
fi
25-
;;
26-
*"cachyos"* )
27-
./scripts/nas.sh
28-
;;
29-
*)
30-
if [[ $(uname -o) == "Darwin" ]]; then
31-
./scripts/mac.sh
32-
elif [[ $DEV_WORKSPACE != "" ]]; then
33-
./scripts/devcontainer.sh
34-
else
35-
echo \
36-
"
11+
*"android"*)
12+
base_install "phone"
13+
;;
14+
*"azure"*) # github action
15+
export CI=true
16+
sudo apt-get install -y yq
17+
if [[ $DEV_WORKSPACE != "" ]]; then
18+
base_install "devcontainer"
19+
else
20+
base_install "ubuntu"
21+
fi
22+
;;
23+
*"generic"*)
24+
sudo apt-get install yq
25+
if [[ $DEV_WORKSPACE != "" ]]; then
26+
base_install "devcontainer"
27+
else
28+
base_install "ubuntu"
29+
fi
30+
;;
31+
*"cachyos"*)
32+
sudo pacman -S --needed --noconfirm yq
33+
base_install "nas"
34+
;;
35+
*)
36+
if [[ $DEV_WORKSPACE != "" ]]; then
37+
base_install "devcontainer"
38+
else
39+
echo \
40+
"
3741
Unknown system: $(uname -a)
3842
KTHNXBYE
3943
"
40-
exit 1
41-
fi
42-
;;
44+
exit 1
45+
fi
46+
;;
4347
esac
44-

scripts/base_install.sh

Lines changed: 133 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,141 @@
1-
function base_install() {
2-
local system="$1"
3-
4-
if [[ "$system" == "arch" ]]; then
5-
INFO "Setting up an arch based system"
6-
if [ "$(which yay)" == "" ]; then
7-
INFO "Setting up yay..."
8-
[ ! -d /tmp/yay ] && git clone https://aur.archlinux.org/yay.git /tmp/yay
9-
cd /tmp/yay || exit 1
10-
makepkg -si --noconfirm
11-
cd - || exit 1
12-
else
13-
INFO "yay already installed"
14-
fi
15-
16-
pkg_install="pac_install"
17-
alt_install="yay_install"
18-
19-
LUA="lua"
20-
NVIM="nvim"
21-
GO="go"
22-
FZF="fzf"
23-
LAZYDOCKER="lazydocker"
24-
NODEJS="node"
25-
else
26-
INFO "Setting up an ubuntu based system"
27-
28-
pkg_install="apt_install"
29-
alt_install="pacstall_install"
30-
31-
install_chaotic
32-
33-
LUA="lua5.4"
34-
NVIM="neovim"
35-
GO="golang"
36-
FZF="fzf-bin"
37-
LAZYDOCKER="lazydocker-bin"
38-
NODEJS="nodejs-deb"
1+
_run_alias_or_func() { # _run_alias_or_func <name>
2+
local name="$1"
3+
if alias "$name" >/dev/null 2>&1; then
4+
# Re-parse so alias expands
5+
eval "$name"
6+
return $?
397
fi
408

41-
INFO "Setting up shell..."
42-
$pkg_install \
43-
btop \
44-
curl \
45-
iftop \
46-
pass \
47-
python3 \
48-
python3-pip \
49-
ripgrep \
50-
tmux \
51-
wget
52-
53-
# install fonts
54-
install_fonts
55-
56-
zsh_extras
57-
58-
install_starship
59-
60-
install_lazygit
61-
62-
INFO "Installing developer tools..."
63-
if [ ! -d "$HOME/workspace" ]; then
64-
mkdir -p "$HOME/workspace"
9+
if typeset -f "$name" >/dev/null 2>&1 || declare -f "$name" >/dev/null 2>&1; then
10+
"$name"
11+
return $?
6512
fi
6613

67-
$pkg_install \
68-
cmake \
69-
gcc \
70-
$GO \
71-
llvm \
72-
$LUA \
73-
luarocks \
74-
python3-setuptools
75-
76-
$alt_install \
77-
$FZF \
78-
$LAZYDOCKER
79-
80-
INFO "Installing NEOVIM"
81-
$alt_install \
82-
$NVIM
83-
84-
INFO "Installing LazyVim Dependencies"
85-
86-
$alt_install \
87-
$NODEJS
88-
89-
pip3_install \
90-
neovim \
91-
pynvim==0.5.2
92-
93-
install_rust
94-
95-
INFO "Installing Lazy Dependencies"
96-
$pkg_install \
97-
python3-debugpy \
98-
python3-virtualenv \
99-
xclip
100-
101-
sudo npm install -g neovim tree-sitter
102-
103-
install_rvm
104-
105-
INFO "Install Devcontainer dependencies"
106-
sudo npm install -g @devcontainers/cli
14+
printf 'extras: "%s" is not an alias or function in this shell\n' "$name" >&2
15+
return 127
16+
}
10717

108-
INFO "Setting up docker..."
109-
$pkg_install \
110-
ca-certificates \
111-
gnupg
112-
if [ "$system" != "arch" ]; then
113-
$pkg_install \
114-
apt-transport-https \
115-
curl \
116-
software-properties-common
117-
fi
18+
# helpers
19+
_do() {
20+
"$@"
21+
}
11822

119-
docker_install
23+
function base_install() {
24+
source "$DOTFILES/scripts/read_yaml.sh"
25+
source "$DOTFILES/scripts/utils.sh"
12026

121-
increase_network_kernel_mem
27+
local system="$1"
28+
local file="$DOTFILES/scripts/configs/$system.yml"
29+
30+
INFO "Collecting packages for $system ($file)"
31+
collect_yaml_lists "$file"
32+
33+
local i name orig
34+
# run the most basic install first then run some required commands
35+
36+
INFO "Running base program install"
37+
for i in "${!categories[@]}"; do
38+
name="${categories[$i]}"
39+
orig="${orig_keys[$i]}"
40+
41+
# materialize the dynamically-named array into pkgs[]
42+
eval 'pkgs=( "${'"$name"'[@]}" )'
43+
44+
[ ${#pkgs[@]} -eq 0 ] && continue
45+
46+
case "$orig" in
47+
base-ubuntu)
48+
_do apt-install "${pkgs[@]}"
49+
;;
50+
base-arch)
51+
_do pac_install "${pkgs[@]}"
52+
;;
53+
base-phone)
54+
_do pkg_install "${pkg[@]}"
55+
;;
56+
esac
57+
done
58+
59+
INFO "Updated dotfile submodules"
60+
git submodule update --init --recursive
61+
62+
INFO "Setting zsh as default shell"
63+
sudo usermod -s "$(which zsh)" "$(whoami)"
64+
65+
INFO "Creating symlinks"
66+
sym_links
67+
68+
INFO "Running system install"
69+
for i in "${!categories[@]}"; do
70+
name="${categories[$i]}"
71+
orig="${orig_keys[$i]}"
72+
73+
# materialize the dynamically-named array into pkgs[]
74+
eval 'pkgs=( "${'"$name"'[@]}" )'
75+
76+
[ ${#pkgs[@]} -eq 0 ] && continue
77+
78+
case "$orig" in
79+
pacstall)
80+
_do pacstall_install "${pkgs[@]}"
81+
;;
82+
pac)
83+
_do pac_install "${pkgs[@]}"
84+
;;
85+
yay)
86+
_do yay_install "${pkgs[@]}"
87+
;;
88+
apt | apt-get)
89+
_do ap_update
90+
_do apt_install "${pkgs[@]}"
91+
;;
92+
pkg)
93+
_do pkg_install "${pkgs[@]}"
94+
;;
95+
pip | pip3 | pipx)
96+
_do pip3_install "${pkgs[@]}"
97+
;;
98+
npm | node | npm_global)
99+
_do npm_install "${pkgs[@]}"
100+
;;
101+
brew | homebrew)
102+
_do brew_install "${pkgs[@]}"
103+
;;
104+
extras)
105+
local x
106+
for x in "${pkgs[@]}"; do
107+
_run_alias_or_func "$x" || return $?
108+
done
109+
;;
110+
*)
111+
ERROR 'No handler for category "%s"; items:\n' "$orig"
112+
ERROR ' - %s\n' "${pkgs[@]}"
113+
;;
114+
esac
115+
done
116+
117+
INFO "Running any final setups"
118+
for i in "${!categories[@]}"; do
119+
name="${categories[$i]}"
120+
orig="${orig_keys[$i]}"
121+
122+
# materialize the dynamically-named array into pkgs[]
123+
eval 'pkgs=( "${'"$name"'[@]}" )'
124+
125+
[ ${#pkgs[@]} -eq 0 ] && continue
126+
127+
case "$orig" in
128+
final-ubuntu)
129+
_do apt-install "${pkgs[@]}"
130+
;;
131+
final-arch)
132+
_do pac_install "${pkgs[@]}"
133+
;;
134+
final-phone)
135+
_do pkg_install "${pkg[@]}"
136+
;;
137+
esac
138+
done
139+
140+
INFO "Finished setting up system."
122141
}

scripts/configs/devcontainer.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
base-ubuntu:
2+
- build-essential
3+
- git
4+
- stow
5+
- zsh
6+
apt-get:
7+
- fd-find
8+
- fuse
9+
- lua5.4
10+
- luarocks
11+
- pass
12+
- python3-venv
13+
- pipx
14+
- ripgrep
15+
- software-properties-common
16+
- wget
17+
- unzip
18+
extras:
19+
- install_chaotic # install pacstall
20+
- install_rust
21+
pip3:
22+
- neovim
23+
- pynvim==0.5.2
24+
pacstall:
25+
- fzf-bin
26+
- neovim
27+
- nodejs-deb
28+
final-ubuntu:
29+
- zsh_extras
30+
- install_starship
31+
- install_lazygit
32+
- devcontainer_extras

0 commit comments

Comments
 (0)