Makefile (3459B)
1 # Makefile for home 2 HOSTS = $(shell nix flake show --json | yq '.nixosConfigurations.[] | key') 3 HOSTS_BUILD = $(addprefix host/, $(addsuffix /build,$(HOSTS))) 4 BUILDER_HOST = vincent@shikoku.home 5 6 hosts: ${HOSTS_BUILD} 7 echo ${HOSTS_BUILD} ${HOSTS} 8 9 host/%/build: FORCE 10 nix build .#nixosConfigurations.$*.config.system.build.toplevel --no-link 11 host/%/boot: FORCE 12 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@$*.home --flake .#$* boot 13 host/%/switch: FORCE 14 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@$*.home --flake .#$* switch 15 16 host/shikoku/boot: 17 nixos-rebuild --build-host root@shikoku.home --target-host root@shikoku.home --flake .#shikoku boot 18 host/shikoku/switch: 19 nixos-rebuild --build-host root@shikoku.home --target-host root@shikoku.home --flake .#shikoku switch 20 host/kerkouane/boot: 21 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@kerkouane.vpn --flake .#kerkouane boot 22 host/kerkouane/switch: 23 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@kerkouane.vpn --flake .#kerkouane switch 24 25 host/demeter/boot: 26 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@192.168.1.182 --flake .#demeter boot 27 host/demeter/switch: 28 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@192.168.1.182 --flake .#demeter switch 29 host/athena/boot: 30 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@192.168.1.183 --flake .#athena boot 31 host/athena/switch: 32 nixos-rebuild --build-host ${BUILDER_HOST} --target-host root@192.168.1.183 --flake .#athena switch 33 34 35 boot: 36 sudo nixos-rebuild --flake .# boot 37 switch: 38 sudo nixos-rebuild --flake .# switch 39 dry-build: 40 nixos-rebuild --flake .# dry-build 41 build: 42 nixos-rebuild --flake .# build 43 44 FORCE: 45 46 # Old – to be removed 47 # Variables 48 EMACS = 49 ifndef EMACS 50 EMACS = "emacs" 51 endif 52 53 DOTEMACS = ~/.config/emacs 54 DOTGNUS = ~/.config/gnus 55 ETCNIXOS = /etc/nixos 56 57 # Targets 58 .PHONY: all 59 all: switch 60 61 .PHONY: update 62 update: 63 nix-channel --update 64 65 .PHONY: install-hooks 66 install-hooks: 67 if [ -e .git ]; then nix-shell -p git --run 'git config core.hooksPath .githooks'; fi 68 69 .PHONY: pre-commit 70 pre-commit: README.md fmt 71 72 .PHONY: fmt 73 fmt: 74 -nixpkgs-fmt *.nix nix lib overlays pkgs systems tools users 75 76 # Cleaning 77 .PHONY: clean 78 clean: clean-system clean-results 79 80 .PHONY: clean-system 81 clean-system: 82 nix-env --profile /nix/var/nix/profiles/system --delete-generations 15d 83 84 .PHONY: clean-results 85 clean-results: 86 unlink results 87 88 .PHONY: clean-www 89 clean-www: 90 -rm -rvf *.elc 91 -rm -rv ~/.org-timestamps/* 92 93 .PHONY: www 94 www: 95 (cd www; make) 96 97 # Documentation build and publishing 98 .PHONY: update-docs 99 update-docs: 100 @echo "Updating docs references…" 101 $(EMACS) --batch --directory $(DOTEMACS)/lisp/ \ 102 --load lib/lisp/docs.el \ 103 --funcall update-docs 104 105 README.md: README.org 106 @echo "Updating README.md…" 107 $(EMACS) --batch --directory $(DOTEMACS)/lisp/ \ 108 --load lib/lisp/docs.el \ 109 --funcall update-readme-md 110 111 # Setup and doctor 112 .PHONY: doctor 113 doctor: 114 @echo "Validate the environment" 115 @readlink $(DOTEMACS) || $(error $(DOTEMACS) is not correctly linked, you may need to run setup) 116 @readlink $(DOTNIXPKGS) || $(error $(DOTNIXPKGS) is not correctly linked, you may need to run setup) 117 118 .PHONY: setup 119 setup: $(DOTEMACS) $(DOTGNUS) 120 121 $(DOTEMACS): 122 @echo "Link $(DOTEMACS) to $(CURDIR)/tools/emacs" 123 @ln -s $(CURDIR)/tools/emacs $(DOTEMACS) 124 125 $(DOTGNUS): 126 @echo "Link $(DOTGNUs) to $(CURDIR)/tools/gnus" 127 @ln -s $(CURDIR)/tools/gnus $(DOTGNUS)