Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (56 loc) · 2.47 KB
/
Copy pathMakefile
File metadata and controls
69 lines (56 loc) · 2.47 KB
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
.PHONY: switch check update skills-update mas-update test fmt drift packages packages-lock
# Picked from the machine itself, so `make switch` needs no flag and cannot
# be pointed at the wrong host by accident.
HOST := $(shell scutil --get LocalHostName)
FLAKE := $(shell pwd)
# Apply the configuration. This is the only command needed day to day.
switch:
@sudo darwin-rebuild switch --flake "$(FLAKE)#$(HOST)"
# Evaluate and dry-build without touching the system.
check:
@nix flake check --no-build
@nix build "$(FLAKE)#darwinConfigurations.$(HOST).system" --dry-run
# Move everything forward. Homebrew upgrades are deliberate rather than part
# of every activation, so they happen here instead of in onActivation.
#
# There is no global `mise upgrade`: [tools] is empty on both machines, so it
# would be a no-op. Project tools upgrade inside their own directories.
update:
@nix flake update
@$(MAKE) --no-print-directory switch
@brew upgrade
@$(MAKE) --no-print-directory packages-lock
@$(MAKE) --no-print-directory mas-update
# Move only the skills-* inputs, so a skill can be picked up (say, after a
# push to skippednote/skills) without dragging nixpkgs along.
skills-update:
@nix flake update $$(nix flake metadata --json | jq -r '.locks.nodes.root.inputs | keys[] | select(startswith("skills-"))')
@$(MAKE) --no-print-directory switch
# homebrew.masApps installs but does not upgrade.
# mas is declared on skippednote only, and cleanup = "zap" actively removes
# it from skippedbook - so an unguarded `mas upgrade` made `make update` fail
# there on its last line, after the switch had already run.
mas-update:
@command -v mas >/dev/null 2>&1 && mas upgrade || echo " mas not installed on $(HOST); skipped"
# Stubbed harness for bootstrap.sh; proves control flow, not behaviour.
test:
@bash tests/bootstrap.sh
# Format the nix files.
fmt:
@nix fmt
# Report where this machine has drifted from the repo.
drift:
@bash scripts/drift-check.sh
# List the Nix packages actually installed in this machine's user profile.
# Reads the live profile rather than the flake, so it shows what is there
# rather than what should be.
packages:
@nix-store -q --references /etc/profiles/per-user/$(USER) \
| xargs -n1 nix-store -q --references \
| sed 's|/nix/store/[a-z0-9]*-||' \
| grep -vE -- '-(man|doc|info|dev|debug)$$' \
| sort -u
# Regenerate packages.lock. Run this whenever the package set changes, and
# commit the result alongside the change.
packages-lock:
@bash scripts/packages-lock.sh