Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. TESTS = \
  2. tests/connect.bats \
  3. tests/executables.bats \
  4. tests/mail.bats \
  5. tests/mjru.bats \
  6. tests/guix.bats \
  7. tests/ssh-mjru.bats \
  8. tests/ssh-home.bats
  9. .PHONY: clean-guile
  10. clean-guile:
  11. rm -rf $(HOME)/.cache/guile/ccache
  12. .PHONY: clean-nix
  13. clean-nix:
  14. rm -rf $(HOME)/.cache/nix
  15. .PHONY: clean
  16. clean: clean-guile clean-nix
  17. rm -rf test-tmp
  18. rm -f dotfiles/nix/result
  19. .PHONY: check
  20. check:
  21. mkdir test-tmp
  22. gpg --quiet --decrypt dhall/ssh/ssh.dhall.gpg | dhall text > test-tmp/config
  23. bats $(TESTS)
  24. .PHONY: benchmark
  25. benchmark:
  26. emacs --eval "(progn (with-current-buffer (get-buffer \"*Benchmark Init Results Tabulated*\") (princ (buffer-substring-no-properties (point-min) (point-max)) #'external-debugging-output)) (kill-emacs))"
  27. MODULES = dotfiles/guixsd/modules
  28. HOSTNAME = $(shell hostname)
  29. QEMU_FLAGS = \
  30. -vnc :22 \
  31. -daemonize \
  32. -m 4096 \
  33. -smp 2 \
  34. -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  35. define guix-time-machine-arguments
  36. guix time-machine -C dotfiles/channels-current.scm
  37. endef
  38. define guix-system-vm-arguments
  39. system vm -L $(MODULES) --no-offload dotfiles/system/$(1)
  40. endef
  41. guix-system-vm-configurations = \
  42. guixsd \
  43. jenkins \
  44. stumpwm
  45. guix-system-vm-configuration-prefix := guix-system-vm-configuration-
  46. $(foreach configuration,$(guix-system-vm-configurations),$(guix-system-vm-configuration-prefix)-$(configuration)):
  47. guix $(call guix-system-vm-arguments,$(guix-system-vm-configuration-prefix),$@)
  48. time-machine-guix-system-vm-configuration-prefix = time-machine-guix-system-vm-configuration-
  49. $(foreach configuration,$(guix-system-vm-configurations),$(time-machine-guix-system-vm-configuration-prefix)$(configuration)):
  50. $(call guix-time-machine-arguments) -- $(call guix-system-vm-arguments,$(subst $(time-machine-guix-system-vm-configuration-prefix),vm-image-,$@).tmpl)
  51. .PHONY: extension-graph
  52. extension-graph:
  53. guix system -L $(MODULES) extension-graph dotfiles/guixsd/guixsd.scm | xdot -
  54. .PHONY: shepherd-graph
  55. shepherd-graph:
  56. guix system -L $(MODULES) shepherd-graph dotfiles/guixsd/guixsd.scm | xdot -
  57. .PHONY: configure
  58. configure:
  59. ./configure
  60. dotfiles/guile/ssh.txt: dotfiles/guile/ssh.scm
  61. guile dotfiles/guile/ssh.scm > dotfiles/guile/ssh.txt
  62. .PHONY:
  63. decrypt:
  64. gpg --quiet --decrypt dotfiles/guixsd/modules/home/config/openssh.scm.gpg > dotfiles/guixsd/modules/home/config/openssh.scm
  65. .PHONY: dotfiles/scripts/nix-ssh-known-hosts-to-file.scm
  66. dotfiles/scripts/nix-ssh-known-hosts-to-file.scm:
  67. mkdir -p private_dot_ssh
  68. $(shell guix build -f dotfiles/scripts/nix-ssh-known-hosts-to-file.scm)/bin/run.scm > private_dot_ssh/known_hosts2
  69. .PHONY: dotfiles/guixsd/home/guixsd.scm
  70. dotfiles/guixsd/home/guixsd.scm:
  71. guix home -L dotfiles/guixsd/modules build dotfiles/guixsd/home/guixsd.scm
  72. .PHONY: dotfiles/nix/flake.lock
  73. dotfiles/nix/flake.lock:
  74. sh -c 'set -e; cd dotfiles/nix || exit 1; nix flake lock --update-input nixpkgs'
  75. .PHONY: dotfiles/nix/flake.nix
  76. dotfiles/nix/flake.nix:
  77. sh -c 'set -e; cd dotfiles/nix || exit 1; ./flake.nix'
  78. .PHONY: dotfiles/dns/flake.nix
  79. dotfiles/dns/flake.nix:
  80. sh -c 'set -e; cd dotfiles/dns || exit 1; ./flake.nix'
  81. .PHONY: dotfiles/nix/nix.conf
  82. dotfiles/nix/nix.conf:
  83. sudo mkdir -p /etc/nix
  84. sudo install -m644 dotfiles/nix/nix.conf /etc/nix/nix.conf
  85. .PHONY: dotfiles/nix/firefox/generated-firefox-addons.nix
  86. dotfiles/nix/firefox/generated-firefox-addons.nix:
  87. mozilla-addons-to-nix dotfiles/nix/firefox/addons.json dotfiles/nix/firefox/generated-firefox-addons.nix
  88. .PHONY: dotfiles/guixsd/machines.scm
  89. dotfiles/guixsd/machines.scm:
  90. sudo install -m644 dotfiles/guixsd/machines.scm /etc/guix
  91. .PHONY: dot_config/transmission/settings.json.gpg
  92. dot_config/transmission/settings.json.gpg:
  93. gpg --decrypt dot_config/transmission/settings.json.gpg > $(HOME)/.config/transmission-daemon/settings.json
  94. .PHONY: dot_config/espanso/user/censor.yml.gpg
  95. dot_config/espanso/user/censor.yml.gpg:
  96. gpg --decrypt dot_config/espanso/user/censor.yml.gpg > $(HOME)/.config/espanso/user/censor.yml
  97. .PHONY: dotfiles/mjru/intr.nix
  98. dotfiles/mjru/intr.nix:
  99. dotfiles/mjru/intr.nix > dotfiles/mjru/intr.json
  100. .PHONY: install
  101. install: decrypt dotfiles/guixsd/machines.scm dotfiles/nix/nix.conf dotfiles/scripts/nix-ssh-known-hosts-to-file.scm
  102. dot_local/bin/executable_gpg-unlock > /dev/null
  103. update-desktop-database $(HOME)/.local/share/applications
  104. mkdir -p $(HOME)/.config/mpv/scripts
  105. ln -sf $(HOME)/.nix-profile/share/mpv/scripts/notify-send.lua $(HOME)/.config/mpv/scripts/notify-send.lua
  106. install --mode=755 dotfiles/scripts/guix-channels-update $(HOME)/bin
  107. install --mode=755 dotfiles/scripts/guix-ci $(HOME)/bin
  108. install --mode=755 dotfiles/scripts/guix-package-version $(HOME)/bin
  109. install --mode=755 dotfiles/scripts/guix-profile-to-manifest $(HOME)/bin
  110. install --mode=755 dotfiles/scripts/maintenance $(HOME)/bin
  111. install --mode=755 dotfiles/scripts/sshrc $(HOME)/bin
  112. gpg --decrypt dotfiles/emacs/mjru-network.gpg > $(HOME)/.emacs.d/modules/mjru-network.el
  113. ln -sf $(HOME)/.Xresources $(HOME)/.Xdefaults
  114. install -Dm644 dotfiles/guile/pass.scm $(HOME)/.config/guile/pass.scm
  115. install -Dm644 dotfiles/guile/config.scm $(HOME)/.config/guile/config.scm
  116. guix home --load-path=dotfiles/guixsd/modules reconfigure dotfiles/guixsd/home/$(HOSTNAME).scm
  117. install -Dm644 private_dot_ssh/known_hosts2 $(HOME)/.ssh/known_hosts2
  118. .PHONY: shepherd-restart
  119. shepherd-restart:
  120. $(shell set +e; herd stop root)
  121. rm -f /run/user/$(UID)/shepherd/socket
  122. make install
  123. .PHONY: guile-ihs
  124. guile-ihs:
  125. guix environment --manifest=dotfiles/manifests/majordomo.scm -- sh -c 'type -p ihs'
  126. .PHONY: deploy
  127. deploy:
  128. guix deploy -L $(MODULES) dotfiles/guixsd/deploy.scm
  129. .PHONY: dotfiles/channels-current.scm
  130. dotfiles/channels-current.scm: clean-guile
  131. GUILE_LOAD_PATH="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" \
  132. GUILE_AUTO_COMPILE=0 \
  133. dot_local/bin/executable_guix-latest \
  134. -L dotfiles/guixsd/modules \
  135. --channels=dotfiles/channels-current.scm \
  136. dotfiles/manifests/desktop.scm \
  137. dotfiles/manifests/emacs.scm \
  138. dotfiles/manifests/guix-collection.scm \
  139. dotfiles/manifests/wigust.scm \
  140. dotfiles/guixsd/guixsd.scm
  141. .PHONY: dotfiles/channels-current-local-file.scm
  142. dotfiles/channels-current-local-file.scm: clean-guile
  143. GUILE_LOAD_PATH="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" \
  144. GUILE_AUTO_COMPILE=0 \
  145. dot_local/bin/executable_guix-latest \
  146. --local-file \
  147. --load-path=dotfiles/guixsd/modules \
  148. --channels=dotfiles/channels-current-local-file.scm \
  149. dotfiles/manifests/desktop.scm \
  150. dotfiles/manifests/emacs.scm \
  151. dotfiles/manifests/guix-collection.scm \
  152. dotfiles/manifests/wigust.scm \
  153. dotfiles/guixsd/guixsd.scm \
  154. dotfiles/guixsd/vm1.wugi.info.scm \
  155. dotfiles/guixsd/vm2.wugi.info.scm
  156. .PHONY: dotfiles/packer/build.scm
  157. dotfiles/packer/build.scm:
  158. sh -c 'cd dotfiles/packer; guix build -f build.scm'
  159. guix-system-configurations = \
  160. guixsd \
  161. vm1.wugi.info \
  162. vm2.wugi.info \
  163. ws1.wugi.info
  164. define guix-system-arguments
  165. system build -L $(MODULES) dotfiles/guixsd/$(subst $(1),,$(2)).scm
  166. endef
  167. define guix-package-manifest-arguments
  168. shell -L $(MODULES) --manifest=dotfiles/manifests/$(subst $(1),,$(2)).scm -- exit 0
  169. endef
  170. prefix := guix-system-configuration-
  171. $(foreach configuration,$(guix-system-configurations),guix-system-configuration-$(configuration)):
  172. guix $(call guix-system-arguments,$(prefix),$@)
  173. prefix := time-machine-guix-system-configuration-
  174. $(foreach configuration,$(guix-system-configurations),time-machine-guix-system-configuration-$(configuration)):
  175. $(call guix-time-machine-arguments) -- $(call guix-system-arguments,$(prefix),$@)
  176. prefix := guix-package-manifest-
  177. $(foreach configuration,$(guix-system-configurations),guix-package-manifest-$(configuration)):
  178. $(call guix-package-manifest-arguments,$(prefix),$@)
  179. prefix := time-machine-guix-package-manifest-
  180. $(foreach configuration,$(guix-system-configurations),time-machine-guix-package-manifest-$(configuration)):
  181. $(call guix-time-machine-arguments) -- $(call guix-package-manifest-arguments,$(prefix),$@)
  182. .PHONY: add
  183. add:
  184. cp $(HOME)/.emacs dot_emacs
  185. .PHONY: github
  186. github:
  187. make --directory=dotfiles/maintenance/github
  188. .PHONY: gitlab
  189. gitlab:
  190. make --directory=dotfiles/maintenance/gitlab
  191. .PHONY: home
  192. home:
  193. herd stop root
  194. rm -f /run/user/1000/shepherd/socket
  195. make install
  196. state-to-vc-hostnames = \
  197. sr1-dh507-508 \
  198. sr1-mr13-14 \
  199. sw1-dh507 \
  200. sw1-dh508 \
  201. sw1-mr11 \
  202. sw1-mr12 \
  203. sw1-mr14 \
  204. sw2-dh507 \
  205. sw2-dh508 \
  206. sw2-mr12 \
  207. sw2-mr13 \
  208. sw2-mr14 \
  209. sw4-mr11 \
  210. sw4-mr12 \
  211. sw4-mr13 \
  212. sw4-mr14
  213. guix_repository=$(HOME)/src/git.savannah.gnu.org/git/guix
  214. container_registry=harbor.corp1.majordomo.ru
  215. .ONESHELL:
  216. $(state-to-vc-hostnames):
  217. set -o nounset -o errexit -o pipefail
  218. commit_8=$$(git rev-parse HEAD | cut -c -8)
  219. container=$$($(guix_repository)/pre-inst-env guix pack -f docker-layered -S /bin=bin -L dotfiles/guixsd/modules -e '(@ (packages networking) state-to-vc-$@)')
  220. skopeo copy --insecure-policy docker-archive\:$$container docker://$(container_registry)/monitoring/$@:$$commit_8
  221. guix gc --delete $$container
  222. cd $(HOME)/src/gitlab.intr/cd/state-to-git/apps/*/state-to-git-$@
  223. nix develop git+https://gitlab.intr/nixos/kubernetes --command kustomize edit set image $(container_registry)/monitoring/$@:$$commit_8
  224. if ! git commit --message="apps: $$(basename $$(dirname $$(pwd))): state-to-git-$@: Update image to $$commit_8." kustomization.yaml
  225. then
  226. :
  227. fi
  228. state-to-vc-containers: $(state-to-vc-hostnames)
  229. .PHONY: guix-system-build-channels-current
  230. guix-system-build-channels-current:
  231. sudo --login GUILE_LOAD_PATH="$(PWD)/dotfiles/guixsd/modules:$(GUILE_LOAD_PATH)" \
  232. guix time-machine \
  233. --channels="$(PWD)/dotfiles/channels-current.scm" \
  234. -- system build \
  235. --load-path="$(PWD)/dotfiles/guixsd/modules:$(GUILE_LOAD_PATH)" \
  236. "$(PWD)/dotfiles/guixsd/$(HOSTNAME).scm"
  237. container_registry=docker-registry.wugi.info
  238. .ONESHELL:
  239. util-linux-with-udev:
  240. set -o nounset -o errexit -o pipefail -o xtrace
  241. commit_8=$$(git rev-parse HEAD | cut -c -8)
  242. container=$$(guix pack -f docker -L dotfiles/guixsd/modules --max-layers=100 -S /bin=bin util-linux-with-udev bash coreutils guix-refresh.sh)
  243. skopeo copy --insecure-policy docker-archive\:$$container docker://$(container_registry)/library/$@:$$commit_8
  244. guix gc --delete $$container
  245. cd apps/base/maintenance-guix-refresh-gita
  246. nix develop git+https://gitlab.intr/nixos/kubernetes --command kustomize edit set image $(container_registry)/library/$@:$$commit_8
  247. if ! git commit --message="apps: $$(basename $$(dirname $$(pwd))): maintenance-guix-refresh-gita: Update image to $$commit_8." kustomization.yaml
  248. then
  249. :
  250. fi
  251. .PHONY: all
  252. all: dotfiles/scripts/nix-ssh-known-hosts-to-file.scm