-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot_direnvrc
309 lines (276 loc) · 8.25 KB
/
dot_direnvrc
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# -*- mode: Sh; fill-column: 78; -*-
export_function()
{
local name=$1
local alias_dir=$PWD/.direnv/aliases
mkdir -p "$alias_dir"
PATH_add "$alias_dir"
local target="$alias_dir/$name"
if declare -f "$name" >/dev/null; then
echo "#!$SHELL" > "$target"
declare -f "$name" >> "$target" 2>/dev/null
# Notice that we add shell variables to the function trigger.
echo "$name \$*" >> "$target"
chmod +x "$target"
fi
}
use_haunt()
{
gcroot="${HOME}/.config/guix/gcroots/haunt"
if [ -L "$gcroot" ]
then
rm -v "$gcroot"
fi
PACKAGES_MAINTENANCE=(direnv git sshpass password-store less openssh gnupg)
PACKAGES=(bash coreutils grep findutils which)
eval "$(guix environment --search-paths --root="$gcroot" --pure --load=guix.scm --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
}
use_guix()
{
GUIX_GITHUB_TOKEN="$(pass show github/tokens/GUIX_GITHUB_TOKEN)"
export GUIX_GITHUB_TOKEN
GUIX_PACKAGE_PATH=""
export GUIX_PACKAGE_PATH
packages_maintenance=(
direnv
git
git:send-email
git-cal
gnupg
guile-colorized
guile-readline
inetutils
less
ncurses
openssh
password-store
sshpass
xdot
which
)
export ENV_PACKAGES_MAINTENANCE="${packages_maintenance[@]}"
packages=(help2man guile-sqlite3 guile-gcrypt)
export ENV_PACKAGES="${packages[@]}"
GIT_SSL_CAINFO=/run/current-system/profile/etc/ssl/certs/ca-certificates.crt
export GIT_SSL_CAINFO
SSL_CERT_DIR=/etc/ssl/certs
export SSL_CERT_DIR
NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
export NIX_SSL_CERT_FILE
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
export SSL_CERT_FILE
# https://lists.gnu.org/archive/html/guix-devel/2016-09/msg00859.html
environment()
{
set -x
case "$1" in
build)
guix environment --pure guix --ad-hoc ${ENV_PACKAGES[@]} ${ENV_PACKAGES_MAINTENANCE[@]} -- .direnv/aliases/build
;;
*)
guix environment --pure guix --ad-hoc ${ENV_PACKAGES[@]} ${ENV_PACKAGES_MAINTENANCE[@]} "$@"
;;
esac
}
export_function environment
repl()
{
set -x
./pre-inst-env guix repl -L "$(./pre-inst-env guix build emacs-geiser)"/share/geiser/guile
}
export_function repl
configure()
{
./configure --localstatedir=/var --prefix=
}
export_function configure
build()
{
make -k -j "$(nproc)"
if [ $# -gt 0 ]
then
case "$1" in
refresh)
./pre-inst-env guix refresh -l "${@:2}" \
| cut -d: -f 2 \
| tr ' ' '\n' \
| cut -d@ -f 1 \
| xargs ./pre-inst-env guix build --no-grafts --no-offload
;;
*)
./pre-inst-env guix build --no-grafts --no-offload "$@"
;;
esac
fi
for file in po/*/*.po
do
git update-index --assume-unchanged "$file"
done
}
export_function build
push()
{
sshpass -Ppassphrase -p"$(pass show localhost/ssh/id_rsa_savannah)" git push --set-upstream origin
}
export_function push
pull()
{
sshpass -Ppassphrase -p"$(pass show localhost/ssh/id_rsa_savannah)" git pull --rebase
}
export_function pull
guix_pull()
{
mkdir -p current
guix pull --profile="${PWD}/current/guix" --url="file://${PWD}" --disable-authentication "$@"
}
export_function guix_pull
shell()
{
guix shell ${ENV_PACKAGES[@]} ${ENV_PACKAGES_MAINTENANCE[@]} --development guix "$@"
}
export_function shell
clear
echo "
direnv:
build build a package or just a project if no argument provided
configure run ./configure with predefined parameters
environment WARNING: deprecated: run 'guix environment' with presetted arguments
push push to upstream Git repository
pull pull changes from upstream Git repository
repl run guix repl
shell run 'guix shell' with presetted arguments
guix_pull guix pull current directory
"
export XDG_RUNTIME_DIR="/run/user/$UID"
export EDITOR="$HOME/.guix-profile/bin/emacsclient -nc"
cat <<'EOF'
sudo --login \
GUILE_LOAD_PATH="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" \
"${PWD}/pre-inst-env" guix system build \
--load-path="${HOME}/src/gitlab.com/nonguix/nonguix" \
--load-path="${HOME}/src/cgit.duckdns.org/guix/guix-wigust/guix" \
--load-path="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules" \
"${HOME}/.local/share/chezmoi/dotfiles/guixsd/guixsd.scm"
EOF
}
use_emacs-guix()
{
gcroot="${HOME}/.config/guix/gcroots/guix"
if [ -L "$gcroot" ]
then
rm -v "$gcroot"
fi
PACKAGES_MAINTENANCE=(
direnv
emacs
git
git-cal
gnupg
guile
guile-colorized
guile-irregex
guile-readline
inetutils
less
ncurses
openssh
password-store
sshpass
st
which
xdot
)
PACKAGES=(help2man)
# https://lists.gnu.org/archive/html/guix-devel/2016-09/msg00859.html
eval "$(guix environment --search-paths --root="$gcroot" --pure --load=guix.scm --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
GUILE_LOAD_PATH=$PWD/scheme:$GUILE_LOAD_PATH
export GUILE_LOAD_PATH
GUILE_LOAD_COMPILED_PATH=$PWD/scheme:$GUILE_LOAD_COMPILED_PATH
export GUILE_LOAD_COMPILED_PATH
EMACSLOADPATH="$PWD/elisp:$EMACSLOADPATH"
export EMACSLOADPATH
}
use_dotfiles()
{
check()
{
make check TESTS="tests/connect.bats tests/executables.bats tests/mail.bats tests/mjru.bats" "$@"
}
export_function check
GUILE_LOAD_PATH="${PWD}/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}"
export GUILE_LOAD_PATH
GUIX_PACKAGE_PATH="${PWD}/dotfiles/guixsd/modules:${GUIX_PACKAGE_PATH}"
export GUIX_PACKAGE_PATH
}
use_guile()
{
unset GUIX_PACKAGE_PATH
PACKAGES=(
autoconf
automake
bash
coreutils
flex
gettext
libtool
readline
texinfo
)
PACKAGES_MAINTENANCE=(
direnv
)
gcroot="${HOME}/.config/guix/gcroots/guile"
if [ -L "$gcroot" ]
then
rm -v "$gcroot"
fi
eval "$(guix environment --search-paths --root="$gcroot" --pure guile --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
}
use_fasm()
{
PACKAGES_MAINTENANCE=(bash binutils coreutils direnv)
PACKAGES=(fasm)
eval "$(guix environment --search-paths --pure --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
}
use_artanis()
{
PACKAGES_MAINTENANCE=(bash binutils coreutils direnv)
PACKAGES=(artanis guile@2)
eval "$(guix environment --search-paths --pure --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
}
use_mjru_ci_jenkins()
{
jenkins-jobs()
{
export PYTHONPATH=''
"$HOME/.nix-profile/bin/jenkins-jobs" --conf "$HOME/.config/jenkins_jobs/jenkins_jobs_majordomo.ini" "$@"
}
export_function jenkins-jobs
}
use_mjru_nix()
{
export NIX_ARGS
nix-build()
{
"$HOME/.nix-profile/bin/nix-build" "${NIX_ARGS[@]}" "$@"
}
export_function nix-build
nix-instantiate()
{
"$HOME/.nix-profile/bin/nix-instantiate" "${NIX_ARGS[@]}" "$@"
}
export_function nix-instantiate
nix-shell()
{
NIX_ARGS=("--no-out-link"
"--option" "trusted-public-keys" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.nixos.intr:6VD7bofl5zZFTEwsIDsUypprsgl7r9I+7OGY4WsubFA="
"--option" "builders" "ssh://nixos.intr x86_64-linux"
"--substituters" "https://cache.nixos.org/ https://cache.nixos.intr/")
"$HOME/.nix-profile/bin/nix-shell" "${NIX_ARGS[@]}" "$@"
}
export_function nix-shell
}
use_nixpkgs()
{
echo '+/home/oleg/src/nixpkgs' > .dumbjump
}