aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 83e515585ba1798e077694ed1c69840ccf03cb24 (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
77
78
79
80
81
82
83
84
NIX_FILES = $(shell find . name -name '*.nix' -type f)
MAX_AGE=14d
CHANNEL_FILE=./config/guix/channels.scm
HOSTS=axo daeva owl baal yak koi bard
SYSTEMS=$(patsubst %,systems/%,$(HOSTS))
HOMES=$(patsubst %,homes/%,$(HOSTS))
HOSTNAME=$(shell hostname)
NPROC=$(shell nproc)
CORES=$(guile (max 1 (floor (/ $(NPROC) 4))))
LOAD_PATH=--load-path=./


.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 $(LOAD_PATH) reconfigure $(RECONFIGURE_FLAGS) homes/$(HOSTNAME).scm

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

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

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

.PHONY: lint
lint:
	guix time-machine -C $(CHANNEL_FILE) -- 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 $(LOAD_PATH)

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

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

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

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

.PHONY: iso
iso: iso/installer.scm
	guix time-machine -C $(CHANNEL_FILE) -- system image --cores=$(CORES) --image-type=iso9660 $^

## 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))))" "$<"