dot_direnvrc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. # -*- mode: Sh; fill-column: 78; -*-
  2. export_function()
  3. {
  4. local name=$1
  5. local alias_dir=$PWD/.direnv/aliases
  6. mkdir -p "$alias_dir"
  7. PATH_add "$alias_dir"
  8. local target="$alias_dir/$name"
  9. if declare -f "$name" >/dev/null; then
  10. echo "#!$SHELL" > "$target"
  11. declare -f "$name" >> "$target" 2>/dev/null
  12. # Notice that we add shell variables to the function trigger.
  13. echo "$name \$*" >> "$target"
  14. chmod +x "$target"
  15. fi
  16. }
  17. use_haunt()
  18. {
  19. gcroot="${HOME}/.config/guix/gcroots/haunt"
  20. if [ -L "$gcroot" ]
  21. then
  22. rm -v "$gcroot"
  23. fi
  24. PACKAGES_MAINTENANCE=(direnv git sshpass password-store less openssh gnupg)
  25. PACKAGES=(bash coreutils grep findutils which)
  26. eval "$(guix environment --search-paths --root="$gcroot" --pure --load=guix.scm --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
  27. }
  28. use_guix()
  29. {
  30. GUIX_GITHUB_TOKEN="$(pass show github/tokens/GUIX_GITHUB_TOKEN)"
  31. export GUIX_GITHUB_TOKEN
  32. GUIX_PACKAGE_PATH=""
  33. export GUIX_PACKAGE_PATH
  34. packages_maintenance=(
  35. direnv
  36. git
  37. git:send-email
  38. git-cal
  39. gnupg
  40. guile-colorized
  41. guile-readline
  42. inetutils
  43. less
  44. ncurses
  45. openssh
  46. password-store
  47. sshpass
  48. xdot
  49. which
  50. )
  51. export ENV_PACKAGES_MAINTENANCE="${packages_maintenance[@]}"
  52. packages=(help2man guile-sqlite3 guile-gcrypt)
  53. export ENV_PACKAGES="${packages[@]}"
  54. GIT_SSL_CAINFO=/run/current-system/profile/etc/ssl/certs/ca-certificates.crt
  55. export GIT_SSL_CAINFO
  56. SSL_CERT_DIR=/etc/ssl/certs
  57. export SSL_CERT_DIR
  58. NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
  59. export NIX_SSL_CERT_FILE
  60. SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
  61. export SSL_CERT_FILE
  62. # https://lists.gnu.org/archive/html/guix-devel/2016-09/msg00859.html
  63. environment()
  64. {
  65. set -x
  66. case "$1" in
  67. build)
  68. guix environment --pure guix --ad-hoc ${ENV_PACKAGES[@]} ${ENV_PACKAGES_MAINTENANCE[@]} -- .direnv/aliases/build
  69. ;;
  70. *)
  71. guix environment --pure guix --ad-hoc ${ENV_PACKAGES[@]} ${ENV_PACKAGES_MAINTENANCE[@]} "$@"
  72. ;;
  73. esac
  74. }
  75. export_function environment
  76. repl()
  77. {
  78. set -x
  79. ./pre-inst-env guix repl -L "$(./pre-inst-env guix build emacs-geiser)"/share/geiser/guile
  80. }
  81. export_function repl
  82. configure()
  83. {
  84. ./configure --localstatedir=/var --prefix=
  85. }
  86. export_function configure
  87. build()
  88. {
  89. make -k -j "$(nproc)"
  90. if [ $# -gt 0 ]
  91. then
  92. case "$1" in
  93. refresh)
  94. ./pre-inst-env guix refresh -l "${@:2}" \
  95. | cut -d: -f 2 \
  96. | tr ' ' '\n' \
  97. | cut -d@ -f 1 \
  98. | xargs ./pre-inst-env guix build --no-grafts --no-offload
  99. ;;
  100. *)
  101. ./pre-inst-env guix build --no-grafts --no-offload "$@"
  102. ;;
  103. esac
  104. fi
  105. for file in po/*/*.po
  106. do
  107. git update-index --assume-unchanged "$file"
  108. done
  109. }
  110. export_function build
  111. push()
  112. {
  113. sshpass -Ppassphrase -p"$(pass show localhost/ssh/id_rsa_savannah)" git push --set-upstream origin
  114. }
  115. export_function push
  116. pull()
  117. {
  118. sshpass -Ppassphrase -p"$(pass show localhost/ssh/id_rsa_savannah)" git pull --rebase
  119. }
  120. export_function pull
  121. guix_pull()
  122. {
  123. mkdir -p current
  124. guix pull --profile="${PWD}/current/guix" --url="file://${PWD}" --disable-authentication "$@"
  125. }
  126. export_function guix_pull
  127. shell()
  128. {
  129. guix shell ${ENV_PACKAGES[@]} ${ENV_PACKAGES_MAINTENANCE[@]} --development guix "$@"
  130. }
  131. export_function shell
  132. clear
  133. echo "
  134. direnv:
  135. build build a package or just a project if no argument provided
  136. configure run ./configure with predefined parameters
  137. environment WARNING: deprecated: run 'guix environment' with presetted arguments
  138. push push to upstream Git repository
  139. pull pull changes from upstream Git repository
  140. repl run guix repl
  141. shell run 'guix shell' with presetted arguments
  142. guix_pull guix pull current directory
  143. "
  144. export XDG_RUNTIME_DIR="/run/user/$UID"
  145. export EDITOR="$HOME/.guix-profile/bin/emacsclient -nc"
  146. cat <<'EOF'
  147. sudo --login \
  148. GUILE_LOAD_PATH="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" \
  149. "${PWD}/pre-inst-env" guix system build \
  150. --load-path="${HOME}/src/gitlab.com/nonguix/nonguix" \
  151. --load-path="${HOME}/src/cgit.duckdns.org/guix/guix-wigust/guix" \
  152. --load-path="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules" \
  153. "${HOME}/.local/share/chezmoi/dotfiles/guixsd/guixsd.scm"
  154. EOF
  155. }
  156. use_emacs-guix()
  157. {
  158. gcroot="${HOME}/.config/guix/gcroots/guix"
  159. if [ -L "$gcroot" ]
  160. then
  161. rm -v "$gcroot"
  162. fi
  163. PACKAGES_MAINTENANCE=(
  164. direnv
  165. emacs
  166. git
  167. git-cal
  168. gnupg
  169. guile
  170. guile-colorized
  171. guile-irregex
  172. guile-readline
  173. inetutils
  174. less
  175. ncurses
  176. openssh
  177. password-store
  178. sshpass
  179. st
  180. which
  181. xdot
  182. )
  183. PACKAGES=(help2man)
  184. # https://lists.gnu.org/archive/html/guix-devel/2016-09/msg00859.html
  185. eval "$(guix environment --search-paths --root="$gcroot" --pure --load=guix.scm --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
  186. GUILE_LOAD_PATH=$PWD/scheme:$GUILE_LOAD_PATH
  187. export GUILE_LOAD_PATH
  188. GUILE_LOAD_COMPILED_PATH=$PWD/scheme:$GUILE_LOAD_COMPILED_PATH
  189. export GUILE_LOAD_COMPILED_PATH
  190. EMACSLOADPATH="$PWD/elisp:$EMACSLOADPATH"
  191. export EMACSLOADPATH
  192. }
  193. use_dotfiles()
  194. {
  195. check()
  196. {
  197. make check TESTS="tests/connect.bats tests/executables.bats tests/mail.bats tests/mjru.bats" "$@"
  198. }
  199. export_function check
  200. GUILE_LOAD_PATH="${PWD}/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}"
  201. export GUILE_LOAD_PATH
  202. GUIX_PACKAGE_PATH="${PWD}/dotfiles/guixsd/modules:${GUIX_PACKAGE_PATH}"
  203. export GUIX_PACKAGE_PATH
  204. }
  205. use_guile()
  206. {
  207. unset GUIX_PACKAGE_PATH
  208. PACKAGES=(
  209. autoconf
  210. automake
  211. bash
  212. coreutils
  213. flex
  214. gettext
  215. libtool
  216. readline
  217. texinfo
  218. )
  219. PACKAGES_MAINTENANCE=(
  220. direnv
  221. )
  222. gcroot="${HOME}/.config/guix/gcroots/guile"
  223. if [ -L "$gcroot" ]
  224. then
  225. rm -v "$gcroot"
  226. fi
  227. eval "$(guix environment --search-paths --root="$gcroot" --pure guile --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
  228. }
  229. use_fasm()
  230. {
  231. PACKAGES_MAINTENANCE=(bash binutils coreutils direnv)
  232. PACKAGES=(fasm)
  233. eval "$(guix environment --search-paths --pure --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
  234. }
  235. use_artanis()
  236. {
  237. PACKAGES_MAINTENANCE=(bash binutils coreutils direnv)
  238. PACKAGES=(artanis guile@2)
  239. eval "$(guix environment --search-paths --pure --ad-hoc ${PACKAGES[@]} ${PACKAGES_MAINTENANCE[@]} "$@")"
  240. }
  241. use_mjru_ci_jenkins()
  242. {
  243. jenkins-jobs()
  244. {
  245. export PYTHONPATH=''
  246. "$HOME/.nix-profile/bin/jenkins-jobs" --conf "$HOME/.config/jenkins_jobs/jenkins_jobs_majordomo.ini" "$@"
  247. }
  248. export_function jenkins-jobs
  249. }
  250. use_mjru_nix()
  251. {
  252. export NIX_ARGS
  253. nix-build()
  254. {
  255. "$HOME/.nix-profile/bin/nix-build" "${NIX_ARGS[@]}" "$@"
  256. }
  257. export_function nix-build
  258. nix-instantiate()
  259. {
  260. "$HOME/.nix-profile/bin/nix-instantiate" "${NIX_ARGS[@]}" "$@"
  261. }
  262. export_function nix-instantiate
  263. nix-shell()
  264. {
  265. NIX_ARGS=("--no-out-link"
  266. "--option" "trusted-public-keys" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.nixos.intr:6VD7bofl5zZFTEwsIDsUypprsgl7r9I+7OGY4WsubFA="
  267. "--option" "builders" "ssh://nixos.intr x86_64-linux"
  268. "--substituters" "https://cache.nixos.org/ https://cache.nixos.intr/")
  269. "$HOME/.nix-profile/bin/nix-shell" "${NIX_ARGS[@]}" "$@"
  270. }
  271. export_function nix-shell
  272. }
  273. use_nixpkgs()
  274. {
  275. echo '+/home/oleg/src/nixpkgs' > .dumbjump
  276. }