-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
146 lines (92 loc) · 2.89 KB
/
Makefile
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
PATH := $(PWD)/bin:$(PATH)
cpif ?= | cpif
kernel_version := $(shell uname -v)
ifneq (,$(findstring B,$(MAKEFLAGS)))
latexmk_flags = -gg
endif
stow_flags := -R
ifneq (,$(findstring trace,$(MAKEFLAGS)))
stow_flags += -v
endif
stow := stow ${stow_flags}
NW_SRCS := $(shell find src -name '*.nw')
WEIRD_SRCS := \
default.nix \
pkgs/development/node-packages/node-packages.json
SRCS := $(filter-out ${WEIRD_SRCS}, $(shell awk '/<<[^ *]+\.\w+>>=$$/{ gsub(/(<<|>>=)/, ""); print $$0 }' ${NW_SRCS} | sort -u))
NIX_SRCS := $(filter %.nix, ${SRCS}) # pkgs/development/node-packages/node-packages.nix
SH_SRCS := $(filter %.sh, ${SRCS})
OTHER_SRCS := $(filter-out ${NIX_SRCS} ${SH_SRCS} ${TEX_SRCS}, ${SRCS})
TEX_SRCS := $(patsubst src/%.nw,src/%.tex,${NW_SRCS})
.PHONY: all
all:: srcs docs/dotfiles.pdf
.PHONY: deps
deps:
nix flake update --commit-lock-file
.PHONY: srcs
srcs: nix-srcs ${SH_SRCS} ${OTHER_SRCS} ${WEIRD_SRCS}
.PHONY: nix-srcs
nix-srcs: ${NIX_SRCS}
.PHONY: nixpkgs-fmt
nixpkgs-fmt: nix-srcs
nixpkgs-fmt ${NIX_SRCS}
.PHONY: tex
tex: ${TEX_SRCS}
.PHONY: clean
clean:
@ rm -f ${TEX_SRCS} src/dotfiles.nwi
@ latexmk -c -f docs/dotfiles.pdf
@ rm -fr docs/_minted-dotfiles
.PHONY: clobber
clobber:
@ rm -fr docs
.PHONY: install
install: all clean
@ cp -vr docs/* ${PREFIX}
@ echo "theme: jekyll-theme-hacker" >${PREFIX}/_config.yml
@ echo "[PDF](./dotfiles.pdf)" >${PREFIX}/index.md
docs/%.pdf: export TZ='America/Chicago'
docs/%.pdf: src/%.tex src/preamble.tex src/glossary.tex src/%.bib ${TEX_SRCS}
@ mkdir -p $(@D)
latexmk $(latexmk_flags) -cd -f -outdir=$(CURDIR)/$(@D) -pdf $<
@ noindex src/dotfiles
latexmk $(latexmk_flags) -cd -f -outdir=$(CURDIR)/$(@D) -pdf $<
# .INTERMEDIATE: ${TEX_SRCS}
src/%.tex: src/%.nw
@ noweave -delay -latex -n -filter fix-underscores $^ ${cpif} $@
pkgs/development/node-packages/node-packages.json: src/packages.nw
@ mkdir -p $(@D)
@ notangle -R$@ $< ${cpif} $@
pkgs/development/node-packages/node-packages.nix: pkgs/development/node-packages/node-packages.json
@ ${MAKE} -C $(@D)
default.nix: src/packages.nw
@ notangle -R$@ $< ${cpif} $@
${SRCS}::
@ mkdir -p $(@D)
@ notangle -R$@ src/$(basename $@).nw ${cpif} $@
${SH_SRCS}::
chmod a+x $@
.PHONY: .stow-local-ignore
.stow-local-ignore:
@ ls -A1 | sed '/^\(config\|flake\.\(nix\|lock\)\|modules\|nix\|overlays\|pkgs\)$$/d' >$@
stow:: .stow-local-ignore cachix
%: %.enc
@ sops -d $< >${@:.enc=}
.PHONY: build diff dry-build stow switch test
ifneq (,$(findstring NixOS,${kernel_version}))
include Makefile.nixos
else
include Makefile.home-manager
endif
ifeq (,$(findstring Ubuntu,${kernel_version}))
include Makefile.ubuntu
endif
.PHONY: bump-version
bump-version: part ?= patch
bump-version:
semver bump ${part} $(file <VERSION) | tr -d '\n' >VERSION
.PHONY: cachix
cachix: cachix/cachix.dhall
@ mkdir -p ~/.config/$@ $@
@ ${stow} -t ~/.config/$@ $@
stow:: cachix