Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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}" GUILE_AUTO_COMPILE=0 dot_local/bin/executable_guix-latest -L dotfiles/guixsd/modules --channels=dotfiles/channels-current.scm dotfiles/manifests/desktop.scm dotfiles/manifests/emacs.scm dotfiles/manifests/guix-collection.scm dotfiles/manifests/wigust.scm dotfiles/guixsd/guixsd.scm
  132. .PHONY: dotfiles/channels-current-local-file.scm
  133. dotfiles/channels-current-local-file.scm: clean-guile
  134. GUILE_LOAD_PATH="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" \
  135. GUILE_AUTO_COMPILE=0 \
  136. dot_local/bin/executable_guix-latest \
  137. --local-file \
  138. --load-path=dotfiles/guixsd/modules \
  139. --channels=dotfiles/channels-current-local-file.scm \
  140. dotfiles/manifests/desktop.scm \
  141. dotfiles/manifests/emacs.scm \
  142. dotfiles/manifests/guix-collection.scm \
  143. dotfiles/manifests/wigust.scm \
  144. dotfiles/guixsd/guixsd.scm \
  145. dotfiles/guixsd/vm1.wugi.info.scm \
  146. dotfiles/guixsd/vm2.wugi.info.scm
  147. .PHONY: dotfiles/packer/build.scm
  148. dotfiles/packer/build.scm:
  149. sh -c 'cd dotfiles/packer; guix build -f build.scm'
  150. guix-system-configurations = \
  151. guixsd \
  152. vm1.wugi.info \
  153. vm2.wugi.info \
  154. ws1.wugi.info
  155. define guix-system-arguments
  156. system build -L $(MODULES) dotfiles/guixsd/$(subst $(1),,$(2)).scm
  157. endef
  158. define guix-package-manifest-arguments
  159. shell -L $(MODULES) --manifest=dotfiles/manifests/$(subst $(1),,$(2)).scm -- exit 0
  160. endef
  161. prefix := guix-system-configuration-
  162. $(foreach configuration,$(guix-system-configurations),guix-system-configuration-$(configuration)):
  163. guix $(call guix-system-arguments,$(prefix),$@)
  164. prefix := time-machine-guix-system-configuration-
  165. $(foreach configuration,$(guix-system-configurations),time-machine-guix-system-configuration-$(configuration)):
  166. $(call guix-time-machine-arguments) -- $(call guix-system-arguments,$(prefix),$@)
  167. prefix := guix-package-manifest-
  168. $(foreach configuration,$(guix-system-configurations),guix-package-manifest-$(configuration)):
  169. $(call guix-package-manifest-arguments,$(prefix),$@)
  170. prefix := time-machine-guix-package-manifest-
  171. $(foreach configuration,$(guix-system-configurations),time-machine-guix-package-manifest-$(configuration)):
  172. $(call guix-time-machine-arguments) -- $(call guix-package-manifest-arguments,$(prefix),$@)
  173. .PHONY: add
  174. add:
  175. cp $(HOME)/.emacs dot_emacs
  176. .PHONY: github
  177. github:
  178. make --directory=dotfiles/maintenance/github
  179. .PHONY: gitlab
  180. gitlab:
  181. make --directory=dotfiles/maintenance/gitlab
  182. .PHONY: home
  183. home:
  184. herd stop root
  185. rm -f /run/user/1000/shepherd/socket
  186. make install
  187. state-to-vc-hostnames = \
  188. sr1-dh507-508 \
  189. sr1-mr13-14 \
  190. sw1-dh507 \
  191. sw1-dh508 \
  192. sw1-mr11 \
  193. sw1-mr12 \
  194. sw1-mr14 \
  195. sw2-dh507 \
  196. sw2-dh508 \
  197. sw2-mr12 \
  198. sw2-mr13 \
  199. sw2-mr14 \
  200. sw4-mr11 \
  201. sw4-mr12 \
  202. sw4-mr13 \
  203. sw4-mr14
  204. guix_repository=$(HOME)/src/git.savannah.gnu.org/git/guix
  205. container_registry=harbor.corp1.majordomo.ru
  206. .ONESHELL:
  207. $(state-to-vc-hostnames):
  208. set -o nounset -o errexit -o pipefail
  209. commit_8=$$(git rev-parse HEAD | cut -c -8)
  210. container=$$($(guix_repository)/pre-inst-env guix pack -f docker-layered -S /bin=bin -L dotfiles/guixsd/modules -e '(@ (packages networking) state-to-vc-$@)')
  211. skopeo copy --insecure-policy docker-archive\:$$container docker://$(container_registry)/monitoring/$@:$$commit_8
  212. guix gc --delete $$container
  213. cd $(HOME)/src/gitlab.intr/cd/state-to-git/apps/*/state-to-git-$@
  214. nix develop git+https://gitlab.intr/nixos/kubernetes --command kustomize edit set image $(container_registry)/monitoring/$@:$$commit_8
  215. if ! git commit --message="apps: $$(basename $$(dirname $$(pwd))): state-to-git-$@: Update image to $$commit_8." kustomization.yaml
  216. then
  217. :
  218. fi
  219. state-to-vc-containers: $(state-to-vc-hostnames)
  220. .PHONY: guix-system-build-channels-current
  221. guix-system-build-channels-current:
  222. sudo --login GUILE_LOAD_PATH="$(PWD)/dotfiles/guixsd/modules:$(GUILE_LOAD_PATH)" \
  223. guix time-machine \
  224. --channels="$(PWD)/dotfiles/channels-current.scm" \
  225. -- system build \
  226. --load-path="$(PWD)/dotfiles/guixsd/modules:$(GUILE_LOAD_PATH)" \
  227. "$(PWD)/dotfiles/guixsd/$(HOSTNAME).scm"
  228. container_registry=docker-registry.wugi.info
  229. .ONESHELL:
  230. util-linux-with-udev:
  231. set -o nounset -o errexit -o pipefail -o xtrace
  232. commit_8=$$(git rev-parse HEAD | cut -c -8)
  233. container=$$(guix pack -f docker -L dotfiles/guixsd/modules --max-layers=100 -S /bin=bin util-linux-with-udev bash coreutils guix-refresh.sh)
  234. skopeo copy --insecure-policy docker-archive\:$$container docker://$(container_registry)/library/$@:$$commit_8
  235. guix gc --delete $$container
  236. cd apps/base/maintenance-guix-refresh-gita
  237. nix develop git+https://gitlab.intr/nixos/kubernetes --command kustomize edit set image $(container_registry)/library/$@:$$commit_8
  238. if ! git commit --message="apps: $$(basename $$(dirname $$(pwd))): maintenance-guix-refresh-gita: Update image to $$commit_8." kustomization.yaml
  239. then
  240. :
  241. fi
  242. .PHONY: all
  243. all: dotfiles/scripts/nix-ssh-known-hosts-to-file.scm