Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. dotfiles/guixsd/modules/home/config/openssh.scm.gpg:
  63. gpg --quiet --decrypt dotfiles/guixsd/modules/home/config/openssh.scm.gpg > dotfiles/guixsd/modules/home/config/openssh.scm
  64. .PHONY: dotfiles/scripts/nix-ssh-known-hosts-to-file.scm
  65. dotfiles/scripts/nix-ssh-known-hosts-to-file.scm:
  66. mkdir -p private_dot_ssh
  67. $(shell guix build -f dotfiles/scripts/nix-ssh-known-hosts-to-file.scm)/bin/run.scm > private_dot_ssh/known_hosts2
  68. .PHONY: dotfiles/guixsd/home/guixsd.scm
  69. dotfiles/guixsd/home/guixsd.scm:
  70. guix home -L dotfiles/guixsd/modules build dotfiles/guixsd/home/guixsd.scm
  71. .PHONY: dotfiles/nix/flake.lock
  72. dotfiles/nix/flake.lock:
  73. sh -c 'set -e; cd dotfiles/nix || exit 1; nix flake lock --update-input nixpkgs'
  74. .PHONY: dotfiles/nix/flake.nix
  75. dotfiles/nix/flake.nix:
  76. sh -c 'set -e; cd dotfiles/nix || exit 1; ./flake.nix'
  77. .PHONY: dotfiles/dns/flake.nix
  78. dotfiles/dns/flake.nix:
  79. sh -c 'set -e; cd dotfiles/dns || exit 1; ./flake.nix'
  80. .PHONY: dotfiles/nix/nix.conf
  81. dotfiles/nix/nix.conf:
  82. sudo mkdir -p /etc/nix
  83. sudo install -m644 dotfiles/nix/nix.conf /etc/nix/nix.conf
  84. .PHONY: dotfiles/nix/firefox/generated-firefox-addons.nix
  85. dotfiles/nix/firefox/generated-firefox-addons.nix:
  86. mozilla-addons-to-nix dotfiles/nix/firefox/addons.json dotfiles/nix/firefox/generated-firefox-addons.nix
  87. .PHONY: dotfiles/guixsd/machines.scm
  88. dotfiles/guixsd/machines.scm:
  89. sudo install -m644 dotfiles/guixsd/machines.scm /etc/guix
  90. .PHONY: dot_config/transmission/settings.json.gpg
  91. dot_config/transmission/settings.json.gpg:
  92. gpg --decrypt dot_config/transmission/settings.json.gpg > $(HOME)/.config/transmission-daemon/settings.json
  93. .PHONY: dot_config/espanso/user/censor.yml.gpg
  94. dot_config/espanso/user/censor.yml.gpg:
  95. gpg --decrypt dot_config/espanso/user/censor.yml.gpg > $(HOME)/.config/espanso/user/censor.yml
  96. .PHONY: dotfiles/mjru/intr.nix
  97. dotfiles/mjru/intr.nix:
  98. dotfiles/mjru/intr.nix > dotfiles/mjru/intr.json
  99. .PHONY: install
  100. install: dotfiles/guixsd/modules/home/config/openssh.scm.gpg dotfiles/guixsd/machines.scm dotfiles/nix/nix.conf dotfiles/scripts/nix-ssh-known-hosts-to-file.scm
  101. dot_local/bin/executable_gpg-unlock > /dev/null
  102. update-desktop-database $(HOME)/.local/share/applications
  103. mkdir -p $(HOME)/.config/mpv/scripts
  104. ln -sf $(HOME)/.nix-profile/share/mpv/scripts/notify-send.lua $(HOME)/.config/mpv/scripts/notify-send.lua
  105. install --mode=755 dotfiles/scripts/guix-channels-update $(HOME)/bin
  106. install --mode=755 dotfiles/scripts/guix-ci $(HOME)/bin
  107. install --mode=755 dotfiles/scripts/guix-package-version $(HOME)/bin
  108. install --mode=755 dotfiles/scripts/guix-profile-to-manifest $(HOME)/bin
  109. install --mode=755 dotfiles/scripts/maintenance $(HOME)/bin
  110. install --mode=755 dotfiles/scripts/sshrc $(HOME)/bin
  111. gpg --decrypt dotfiles/emacs/mjru-network.gpg > $(HOME)/.emacs.d/modules/mjru-network.el
  112. ln -sf $(HOME)/.Xresources $(HOME)/.Xdefaults
  113. install -Dm644 dotfiles/guile/pass.scm $(HOME)/.config/guile/pass.scm
  114. install -Dm644 dotfiles/guile/config.scm $(HOME)/.config/guile/config.scm
  115. guix home --load-path=dotfiles/guixsd/modules reconfigure dotfiles/guixsd/home/$(HOSTNAME).scm
  116. install -Dm644 private_dot_ssh/known_hosts2 $(HOME)/.ssh/known_hosts2
  117. .PHONY: shepherd-restart
  118. shepherd-restart:
  119. $(shell set +e; herd stop root)
  120. rm -f /run/user/$(UID)/shepherd/socket
  121. make install
  122. .PHONY: guile-ihs
  123. guile-ihs:
  124. guix environment --manifest=dotfiles/manifests/majordomo.scm -- sh -c 'type -p ihs'
  125. .PHONY: deploy
  126. deploy:
  127. guix deploy -L $(MODULES) dotfiles/guixsd/deploy.scm
  128. .PHONY: dotfiles/channels-current.scm
  129. dotfiles/channels-current.scm: clean-guile
  130. GUILE_LOAD_PATH="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" \
  131. GUILE_AUTO_COMPILE=0 \
  132. dot_local/bin/executable_guix-latest \
  133. -L dotfiles/guixsd/modules \
  134. --channels=dotfiles/channels-current.scm \
  135. dotfiles/manifests/desktop.scm \
  136. dotfiles/manifests/emacs.scm \
  137. dotfiles/manifests/guix-collection.scm \
  138. dotfiles/manifests/wigust.scm \
  139. dotfiles/guixsd/guixsd.scm
  140. .PHONY: dotfiles/channels-current-local-file.scm
  141. dotfiles/channels-current-local-file.scm: clean-guile
  142. GUILE_LOAD_PATH="${HOME}/.local/share/chezmoi/dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" \
  143. GUILE_AUTO_COMPILE=0 \
  144. dot_local/bin/executable_guix-latest \
  145. --local-file \
  146. --load-path=dotfiles/guixsd/modules \
  147. --channels=dotfiles/channels-current-local-file.scm \
  148. dotfiles/manifests/desktop.scm \
  149. dotfiles/manifests/emacs.scm \
  150. dotfiles/manifests/guix-collection.scm \
  151. dotfiles/manifests/wigust.scm \
  152. dotfiles/guixsd/guixsd.scm \
  153. dotfiles/guixsd/vm1.wugi.info.scm \
  154. dotfiles/guixsd/vm2.wugi.info.scm
  155. .PHONY: dotfiles/packer/build.scm
  156. dotfiles/packer/build.scm:
  157. sh -c 'cd dotfiles/packer; guix build -f build.scm'
  158. guix-system-configurations = \
  159. guixsd \
  160. vm1.wugi.info \
  161. vm2.wugi.info \
  162. ws1.wugi.info
  163. define guix-system-arguments
  164. system build -L $(MODULES) dotfiles/guixsd/$(subst $(1),,$(2)).scm
  165. endef
  166. define guix-package-manifest-arguments
  167. shell -L $(MODULES) --manifest=dotfiles/manifests/$(subst $(1),,$(2)).scm -- exit 0
  168. endef
  169. prefix := guix-system-configuration-
  170. $(foreach configuration,$(guix-system-configurations),guix-system-configuration-$(configuration)):
  171. guix $(call guix-system-arguments,$(prefix),$@)
  172. prefix := time-machine-guix-system-configuration-
  173. $(foreach configuration,$(guix-system-configurations),time-machine-guix-system-configuration-$(configuration)):
  174. $(call guix-time-machine-arguments) -- $(call guix-system-arguments,$(prefix),$@)
  175. prefix := guix-package-manifest-
  176. $(foreach configuration,$(guix-system-configurations),guix-package-manifest-$(configuration)):
  177. $(call guix-package-manifest-arguments,$(prefix),$@)
  178. prefix := time-machine-guix-package-manifest-
  179. $(foreach configuration,$(guix-system-configurations),time-machine-guix-package-manifest-$(configuration)):
  180. $(call guix-time-machine-arguments) -- $(call guix-package-manifest-arguments,$(prefix),$@)
  181. .PHONY: add
  182. add:
  183. cp $(HOME)/.emacs dot_emacs
  184. .PHONY: github
  185. github:
  186. make --directory=dotfiles/maintenance/github
  187. .PHONY: gitlab
  188. gitlab:
  189. make --directory=dotfiles/maintenance/gitlab
  190. .PHONY: home
  191. home:
  192. herd stop root
  193. rm -f /run/user/1000/shepherd/socket
  194. make install
  195. state-to-vc-hostnames = \
  196. sr1-dh507-508 \
  197. sr1-mr13-14 \
  198. sw1-dh507 \
  199. sw1-dh508 \
  200. sw1-mr11 \
  201. sw1-mr12 \
  202. sw1-mr14 \
  203. sw2-dh507 \
  204. sw2-dh508 \
  205. sw2-mr12 \
  206. sw2-mr13 \
  207. sw2-mr14 \
  208. sw4-mr11 \
  209. sw4-mr12 \
  210. sw4-mr13 \
  211. sw4-mr14
  212. guix_repository=$(HOME)/src/git.savannah.gnu.org/git/guix
  213. container_registry=harbor.corp1.majordomo.ru
  214. .ONESHELL:
  215. $(state-to-vc-hostnames):
  216. set -o nounset -o errexit -o pipefail
  217. commit_8=$$(git rev-parse HEAD | cut -c -8)
  218. container=$$($(guix_repository)/pre-inst-env guix pack -f docker-layered -S /bin=bin -L dotfiles/guixsd/modules -e '(@ (packages networking) state-to-vc-$@)')
  219. skopeo copy --insecure-policy docker-archive\:$$container docker://$(container_registry)/monitoring/$@:$$commit_8
  220. guix gc --delete $$container
  221. cd $(HOME)/src/gitlab.intr/cd/state-to-git/apps/*/state-to-git-$@
  222. nix develop git+https://gitlab.intr/nixos/kubernetes --command kustomize edit set image $(container_registry)/monitoring/$@:$$commit_8
  223. if ! git commit --message="apps: $$(basename $$(dirname $$(pwd))): state-to-git-$@: Update image to $$commit_8." kustomization.yaml
  224. then
  225. :
  226. fi
  227. state-to-vc-containers: $(state-to-vc-hostnames)
  228. .PHONY: guix-system-build-channels-current
  229. guix-system-build-channels-current:
  230. sudo --login GUILE_LOAD_PATH="$(PWD)/dotfiles/guixsd/modules:$(GUILE_LOAD_PATH)" \
  231. guix time-machine \
  232. --channels="$(PWD)/dotfiles/channels-current.scm" \
  233. -- system build \
  234. --load-path="$(PWD)/dotfiles/guixsd/modules:$(GUILE_LOAD_PATH)" \
  235. "$(PWD)/dotfiles/guixsd/$(HOSTNAME).scm"
  236. container_registry=docker-registry.wugi.info
  237. .ONESHELL:
  238. util-linux-with-udev:
  239. set -o nounset -o errexit -o pipefail -o xtrace
  240. commit_8=$$(git rev-parse HEAD | cut -c -8)
  241. container=$$(guix pack -f docker -L dotfiles/guixsd/modules --max-layers=100 -S /bin=bin util-linux-with-udev bash coreutils guix-refresh.sh)
  242. skopeo copy --insecure-policy docker-archive\:$$container docker://$(container_registry)/library/$@:$$commit_8
  243. guix gc --delete $$container
  244. cd apps/base/maintenance-guix-refresh-gita
  245. nix develop git+https://gitlab.intr/nixos/kubernetes --command kustomize edit set image $(container_registry)/library/$@:$$commit_8
  246. if ! git commit --message="apps: $$(basename $$(dirname $$(pwd))): maintenance-guix-refresh-gita: Update image to $$commit_8." kustomization.yaml
  247. then
  248. :
  249. fi
  250. container_registry=docker-registry.wugi.info
  251. .ONESHELL:
  252. haproxy:
  253. set -o nounset -o errexit -o pipefail -o xtrace
  254. commit_8=$$(git rev-parse HEAD | cut -c -8)
  255. container=$$(guix pack -f docker --max-layers=100 -S /sbin=sbin haproxy)
  256. skopeo copy --insecure-policy docker-archive\:$$container docker://$(container_registry)/library/$@:$$commit_8
  257. container_registry=harbor.home.wugi.info
  258. .ONESHELL:
  259. isc-dhcp:
  260. set -o nounset -o errexit -o pipefail -o xtrace
  261. commit_8=$$(git rev-parse HEAD | cut -c -8)
  262. container=$$(guix system image --load-path=/home/oleg/.local/share/chezmoi/dotfiles/guixsd/modules --max-layers=100 -t docker --network dotfiles/guixsd/docker-image-isc-dhcp.scm)
  263. skopeo copy docker-archive\:$$container docker://$(container_registry)/library/$@:$$commit_8
  264. container_registry=harbor.home.wugi.info
  265. .ONESHELL:
  266. guix-image-workstation: dotfiles/guixsd/modules/home/config/openssh.scm.gpg
  267. set -o nounset -o errexit -o pipefail -o xtrace
  268. commit_8=$$(git rev-parse HEAD | cut -c -8)
  269. container=$$(GUILE_LOAD_PATH="dotfiles/guixsd/modules:${GUILE_LOAD_PATH}" GUIX_PACKAGE_PATH="dotfiles/guixsd/modules:${GUIX_PACKAGE_PATH}" guix time-machine --channels=dotfiles/channels-current-guix-image-workstation.scm -- system image --substitute-urls='https://guix.wugi.info https://bordeaux.guix.gnu.org https://substitutes.nonguix.org http://ci.guix.trop.in' --max-layers=100 -t docker --network ~/.local/share/chezmoi/dotfiles/guixsd/guix-image-workstation.scm)
  270. skopeo copy docker-archive\:$$container docker://$(container_registry)/library/$@:$$commit_8
  271. echo $(container_registry)/library/$@:$$commit_8
  272. nix-update-inputs:
  273. $(MAKE) -C dotfiles/nix/container-systemd dotfiles-home-manager
  274. $(MAKE) -C dotfiles/nix/container-systemd-taskexecutor original
  275. container-systemd-taskexecutor:
  276. $(MAKE) -C dotfiles/nix/container-systemd-taskexecutor
  277. .PHONY: all
  278. all: dotfiles/scripts/nix-ssh-known-hosts-to-file.scm