-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_once_10-install-packages-linux.sh.tmpl
130 lines (119 loc) · 4.81 KB
/
run_once_10-install-packages-linux.sh.tmpl
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
{{ if (eq .chezmoi.os "linux") -}}
#!/bin/bash
#
# Installs packages once chezmoi setup is over
#
_isInstalled() {
package="$1"
{{ if (eq .os_id "linux-void")}}
sudo xbps-query "${package}" &>/dev/null;
{{ else if (eq .os_id "linux-arch") }}
sudo paru -Qs "${package}" &>/dev/null;
{{ else if or (eq .os_id "linux-debian") (eq .os_id "linux-ubuntu") }}
sudo dpkg -s "${package}" &>/dev/null;
{{ end }}
return $?
}
_installMany() {
# The packages that are not installed will be added to this array
notInstalled=();
for pkg; do
# If package is installed, skip it
_isInstalled "${pkg}"
if [[ $? == 0 ]]; then
echo "${pkg} is already installed.";
continue;
fi;
# Otherwise, ask user if they want to add it to the list of packages
read -p "Add ${pkg}?" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
notInstalled+=("${pkg}");
fi;
printf "\n";
done;
# If package array is empty, don't do anything and stop the function
if [[ "${notInstalled[@]}" == "" ]] ; then
echo "All packages are already installed.";
return;
fi;
# Install all package added to array
printf "Packages not installed:\n";
printf "%s\n" "${notInstalled[@]}";
{{ if (eq .os_id "linux-void")}}
sudo xbps-install -Sv "${notInstalled[@]}";
{{ else if (eq .os_id "linux-arch") }}
sudo paru -S "${notInstalled[@]}";
{{ else if or (eq .os_id "linux-debian") (eq .os_id "linux-ubuntu") }}
sudo apt install "${notInstalled[@]}";
{{ end }}
}
# params: repo name, repo url, repo version, public key url
_addAptRepo() {
find /etc/apt/sources.list.d/ -type f | grep $1 >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo "Adding key from $4";
# TODO: apt-key is depriciated
curl -fsSL $4 | sudo apt-key add -
echo "Adding repo: $1"
echo "deb" $2 $3 "main" | sudo tee "/etc/apt/sources.list.d/$1.list"
sudo apt update >/dev/null 2>&1
return 0;
fi;
return 1;
}
{{ if (eq .os_id "linux-void")}}
{{ if (not (stat "/etc/xbps.d/11-neovim-nightly.conf")) -}}
# Add neovim-nightly repo
if [[ $(xbps-uhelper arch) == *"musl"* ]]; then
echo 'repository=https://ram02z.github.io/neovim-nightly/musl' | sudo tee /etc/xbps.d/11-neovim-nightly.conf
else
echo 'repository=https://ram02z.github.io/neovim-nightly/glibc' | sudo tee /etc/xbps.d/11-neovim-nightly.conf
fi
{{- end }}
packages=("fish-shell" "neovim-nightly" "chrony" "man-pages-devel"
"nnn" "git" "delta" "base-devel" "jq" "fzf" "gnupg"
"curl" "ripgrep" "bottom" "zoxide" "bat" "fd" "nftables"
"hyperfine" "rustup" "trash-cli" "meson" "clang" "syncthing"
"openresolv" "pinentry-tty" "fuzzypkg" "xtools" "dcron");
{{ if .is_laptop }}
packages+=("light");
{{ end }}
{{ if .is_wayland -}}
packages+=("sway" "seatd" "polkit" "firefox" "foot" "poweralertd" "bluez"
"wdisplays" "swaylock" "pipewire" "wireplumber" "pulseaudio-utils" "libspa-bluetooth"
"mpv" "libnotify" "wl-clipboard" "CopyQ" "swayidle" "wtype" "fuse-sshfs"
"font-iosevka" "i3status-rust" "python3-i3ipc" "xdg-utils" "mesa-dri"
"iwd" "wev" "slurp" "grim" "mako" "grimshot" "man-pages-devel" "dumb_runtime_dir"
"iwgtk" "playerctl" "noto-fonts-emoji" "dejavu-fonts-ttf" "gcolor3");
{{- end }}
{{ else if (eq .os_id "linux-arch") }}
# Assumes we are running sway
# Checks if paru has been installed
{{ if not (lookPath "paru") }}
sudo pacman -S --needed base-devel
git clone https://aur.archlinux.org/paru.git /tmp/
cd paru
makepkg -si
rm -rf /tmp/paru
{{ end }}
packages=("sway" "fish" "neovim-nightly-bin" "git-delta-bin");
{{ else if or (eq .os_id "linux-debian") (eq .os_id "linux-ubuntu") }}
{{ $versionCodename := or (get .chezmoi.osRelease "versionCodename") "all" }}
{{ if (eq .os_id "linux-ubuntu") }}
{{ if not (stat (joinPath "/etc/apt/sources.list.d/" "neovim-nightly.list")) -}}
_addAptRepo "neovim-nightly" "http://ppa.launchpad.net/neovim-ppa/unstable/ubuntu" {{ $versionCodename | quote }} "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x9dbb0be9366964f134855e2255f96fcf8231b6dd"
{{- end }}
{{ if not (stat (joinPath "/etc/apt/sources.list.d/" "fish-shell-3.list")) -}}
_addAptRepo "fish-shell-3" "http://ppa.launchpad.net/fish-shell/release-3/ubuntu" {{ $versionCodename | quote }} "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x59fda1ce1b84b3fad89366c027557f056dc33ca5"
{{- end }}
{{ end }}
{{ if not (stat (joinPath "/etc/apt/sources.list.d/" "rust-cli-tools.list")) -}}
# Add apt.cli.rs repo
_addAptRepo "rust-cli-tools" "https://apt.0xe.me" "all" "https://apt.cli.rs/pubkey.asc"
{{ end }}
packages=("fish" "neovim" "python3-neovim" "nnn" "build-essential" "bat-musl"
"fd-musl" "hyperfine-musl" "ripgrep" "git-delta-musl");
{{ end }}
_installMany "${packages[@]}";
# vim: ft=sh
{{- end }}