aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 9936d588eecf2bd86528663d8d42b57f2c1c3d32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
NIX_FILES = $(shell find . name -name '*.nix' -type f)
MAX_AGE=14d
CHANNEL_FILE=./config/guix/channels.scm
HOSTS=h4x daeva owl baal yak koi bard
SYSTEMS=$(patsubst %,systems/%,$(HOSTS))
HOMES=$(patsubst %,homes/%,$(HOSTS))
HOSTNAME=$(shell hostname)

.PHONY: current-system
current-system: config/emacs/emacs.d/init.el homes/$(HOSTNAME) systems/$(HOSTNAME)

.PHONY: list
list:
	@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'

.PHONY: pull
pull:
	guix time-machine -C $(CHANNEL_FILE) -- pull

.PHONY: news
news:
	guix time-machine -C $(CHANNEL_FILE) -- pull --news

.PHONY: update-channels
update-channels:
	guix pull --channels=$(CHANNEL_FILE)
	guix describe --format=channels > $(CHANNEL_FILE)

.PHONY: reconfigure-home
reconfigure-home:
	guix time-machine -C $(CHANNEL_FILE) -- home reconfigure $(RECONFIGURE_FLAGS) homes/$(HOSTNAME).scm

.PHONY: rollback-home
	guix time-machine -C $(CHANNEL_FILE) -- home roll-back homes/$(HOSTNAME).scm

.PHONY: reconfigure-system
reconfigure-system:
	sudo -E guix time-machine -C $(CHANNEL_FILE) -- system reconfigure $(RECONFIGURE_FLAGS) systems/$(HOSTNAME).scm

.PHONY: rollback-system
rollback-system:
	sudo -E guix time-machine -C $(CHANNEL_FILE) -- system roll-back systems/$(HOSTNAME).scm

.PHONY: lint
lint:
	guix lint --load-path=./ ./

.PHONY: refresh
refresh:
	guix time-machine -C $(CHANNEL_FILE) -- refresh

.PHONY: clean
clean:
	-rm -rv result
	-nix-collect-garbage --delete-older-than $(MAX_AGE)

.PHONY: repl
repl:
	guix time-machine -C $(CHANNEL_FILE) -- repl

.PHONY: all-systems
all-systems: $(SYSTEMS)

.PHONY: all-homes
all-homes: $(HOMES)

$(HOMES):
	guix time-machine -C $(CHANNEL_FILE) -- home build --cores=2 $@.scm

.PHONY: $(SYSTEMS)
$(SYSTEMS):
	guix time-machine -C $(CHANNEL_FILE) -- system build --cores=2 $@.scm

## Private targets
config/emacs/emacs.d/init.el config/emacs/emacs.d/early-init.el: config/emacs/emacs.d/emacs.org
	emacs -Q --batch --eval "(progn (require 'ob-tangle) (dolist (file command-line-args-left) (with-current-buffer (find-file-noselect file) (org-babel-tangle))))" "$<"