-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_once_install-packages.sh.tmpl
executable file
·161 lines (141 loc) · 5.76 KB
/
run_once_install-packages.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
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
#!/usr/bin/env bash
set -o xtrace -o errexit
safe_expose_remove() {
environment=$1
executable=$2
if [ -d ${HOME}/.pixi/envs/${environment} ]; then
exposed_exes=$(pixi global list --environment ${environment} | tail -n 3 | head -n 1 | tr ',' '\n')
if [[ " ${exposed_exes[*]} " =~ [[:space:]]${executable}[[:space:]] ]]; then
pixi global expose remove ${executable}
fi
fi
}
export -f safe_expose_remove
install_global_packages() {
package_list=$1
missing_pkgs=$(comm -13 <(ls ${HOME}/.pixi/envs | sort -u) <(sort -u ${package_list}))
if (($(echo ${missing_pkgs} | wc -w) > 0 )); then
pixi global install $(echo ${missing_pkgs} | tr '\n' ' ')
fi
}
export install_global_packages
clean_global_packages() {
package_list=$1
uneeded_pkgs=$(comm -12 <(ls ${HOME}/.pixi/envs | sort -u) <(sort -u ${package_list}))
if (($(echo ${unneeded_pkgs} | wc -w) > 0 )); then
pixi global uninstall $(echo ${missing_pkgs} | tr '\n' ' ')
fi
}
export clean_global_packages
inject_packages() {
environment=$1
package_list=$2
missing_pkgs=$(comm -13 <(pixi global list --environment ${environment} | cut -f 1 -d ' ' | head -n -6 | tail -n +3 | sort -u) <(sort -u ${package_list}))
if (($(echo ${missing_pkgs} | wc -w) > 0 )); then
pixi global install --environment ${environment} $(echo ${missing_pkgs} | tr '\n' ' ')
fi
}
export inject_packages
if [ ! -f $HOME/.pixi/bin/pixi ]; then
curl -fsSL https://pixi.sh/install.sh | bash
if [ ! -f $HOME/.bashrc ]; then
echo 'PATH="${HOME}/.pixi/bin:${PATH}"' >> ${HOME}/.bashrc
else
if [ ! grep -q 'PATH="${HOME}/.pixi/bin:${PATH}"' < ${HOME}/.bashrc ]; then
echo 'PATH="${HOME}/.pixi/bin:${PATH}"' >> ${HOME}/.bashrc
fi
if [ ! grep -q 'unset FPATH' < ${HOME}/.bashrc ]; then
echo 'unset FPATH' >> ${HOME}/.bashrc
fi
fi
fi
export PATH="$HOME/.pixi/bin:${PATH}"
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/package_list
safe_expose_remove moreutils combine
safe_expose_remove moreutils parallel
safe_expose_remove util-linux rename
{{ if eq .chezmoi.os "linux" -}}
safe_expose_remove util-linux kill
{{ end }}
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/conflict_packages
inject_packages perl $HOME/.local/share/chezmoi/dot_config/chezmoi/perl_packages
clean_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/ruby_packages
inject_packages ruby $HOME/.local/share/chezmoi/dot_config/chezmoi/ruby_packages
if [ -z ${SKIP_PYTHON} ]; then
clean_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/python_packages
pixi global install python=3.12
inject_packages python $HOME/.local/share/chezmoi/dot_config/chezmoi/python_packages
fi
if [ -z ${SKIP_R} ]; then
clean_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/r_packages
pixi global install r-base=4.4
inject_packages r-base $HOME/.local/share/chezmoi/dot_config/chezmoi/r_packages
cp ${HOME}/.local/share/chezmoi/dot_config/chezmoi/Rprofile ${HOME}/.pixi/envs/r-base/lib/R/etc/Rprofile.site
fi
{{ if eq .chezmoi.os "linux" -}}
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/linux_packages
safe_expose_remove coreutils kill
safe_expose_remove coreutils uptime
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/conflict_packages_linux
{{ end }}
{{ if eq .chezmoi.os "darwin" -}}
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/macos_packages
brew update
brew bundle install --file=$HOME/.local/share/chezmoi/dot_config/chezmoi/Brewfile_casks
export FULL_INSTALL=1
{{ end }}
if [ ! -z ${FULL_INSTALL} ]; then
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/huge_packages
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/large_packages
else
clean_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/huge_packages
clean_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/large_packages
fi
{{ if eq .chezmoi.arch "amd64" -}}
install_global_packages $HOME/.local/share/chezmoi/dot_config/chezmoi/intel_packages
{{ end }}
micromamba shell init --shell=bash $HOME/micromamba
micromamba shell init --shell zsh
micromamba config prepend channels nodefaults
micromamba config prepend channels bioconda
micromamba config prepend channels conda-forge
micromamba config prepend channels dnachun
# Create config files for rstudio
mkdir -p ${HOME}/.config/rstudio
tee ${HOME}/.config/rstudio/database.conf << EOF
directory=${HOME}/.local/var/lib/rstudio-server
EOF
tee ${HOME}/.config/rstudio/rserver.conf << EOF
rsession-which-r=${HOME}/.pixi/envs/r-base/bin/R
auth-none=1
database-config-file=${HOME}/.config/rstudio/database.conf
server-daemonize=0
server-data-dir=${HOME}/.local/var/run/rstudio-server
server-user=${USER}
EOF
# To add
# citation-langserver
# languagetool-code-comments
# ltrs
# pick
# uutils-coreutils
# uutils-findutils
# skywalking-eyes
# Install
if [ ! -d $HOME/.local/share/zinit ]; then
export NO_INPUT=1
export NO_ANNEXES=1
export ZSH_DISABLE_COMPFIX="true"
bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)"
zsh -c "source $HOME/.zshrc"
fi
if [ ! -d $HOME/.config/base16-shell ]; then
git clone https://github.com/chriskempson/base16-shell.git $HOME/.config/base16-shell
fi
if [ ! -d $HOME/.tmux/plugins/tpm ]; then
git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm
$HOME/.tmux/plugins/tpm/bin/install_plugins
fi
if [ ! -d $HOME/.config/ranger/plugins/ranger_devicons ]; then
git clone https://github.com/alexanderjeurissen/ranger_devicons $HOME/.config/ranger/plugins/ranger_devicons
fi