-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
140 lines (109 loc) · 3.36 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
ENSURE_FLAKES = --extra-experimental-features "nix-command flakes"
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
print-% : ; @echo $*=$($*)
.PHONY: clean
clean:
rm -f du.png
.PHONY: install
install:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix \
| sh -s -- install
.PHONY: uninstall
uninstall:
/nix/nix-installer uninstall
.PHONY: uninstall-darwin
uninstall-darwin:
# https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#using-macos-after-removing-nix-while-nix-darwin-was-still-installed-network-requests-fail
sudo rm /Library/LaunchDaemons/org.nixos.activate-system.plist
sudo launchctl bootout system/org.nixos.activate-system
/nix/nix-installer uninstall
sudo rm /etc/ssl/certs/ca-certificates.crt
.PHONY: post-setup
post-setup:
# Set up allowed signers file
./scripts/setup_allowed_signers.sh
.PHONY: switch
switch:
nix --show-trace run . switch -- --flake .
.PHONY: nixos-switch
nixos-switch: guard-HOST
nixos-rebuild switch --show-trace --flake .#$(HOST)
.PHONY: darwin-switch
darwin-switch: guard-HOST
nix --show-trace $(ENSURE_FLAKES) build .#darwinConfigurations.$(HOST).system
result/sw/bin/darwin-rebuild switch --flake .#$(HOST)
.PHONY: home-switch
home-switch: guard-HOST
nix --show-trace $(ENSURE_FLAKES) build .#homeConfigurations.$(HOST).activationPackage
result/activate
.PHONY: update
update:
nix flake update
.PHONY: update-secrets
update-secrets:
nix flake lock --update-input secrets
.PHONY: update-blocklist
update-blocklist:
nix flake lock --update-input blocklist
.PHONY: update-mine
update-mine: update-secrets update-blocklist
.PHONY: check
check:
nix flake check
.PHONY: lint
lint:
nix run nixpkgs#statix check
nix run nixpkgs#deadnix
# Cleans up old nix generations to free up disk space
.PHONY: gc
gc:
sudo nix-collect-garbage -d
# Opens an image showing the disk space consumed by nix
du: du.png
open du.png
du.png:
nix-du -s=500MB | dot -Tpng > du.png
# Raspberry PI builders based on https://github.com/JamesGuthrie/nix-docker-builder-macos
builders/linux-aarch64/keys/id_ed25519:
ssh-keygen -t ed25519 -f builders/linux-aarch64/keys/id_ed25519 -N '' -C 'nix-docker-builder-client'
builders/linux-aarch64/keys/ssh_host_ed25519_key:
ssh-keygen -t ed25519 -f builders/linux-aarch64/keys/ssh_host_ed25519_key -N '' -C 'nix-docker-builder-host'
builder-keys: builders/linux-aarch64/keys/id_ed25519 builders/linux-aarch64/keys/ssh_host_ed25519_key
.PHONY: builder-image
builder-image:
docker build \
--rm \
-t nix-docker-builder-linux-aarch64 \
-f builders/linux-aarch64/Dockerfile \
builders/linux-aarch64
.PHONY: builder-container
builder-container:
docker run \
--name=nix-docker-builder-linux-aarch64 \
--detach \
--init \
-p 3022:22 \
nix-docker-builder-linux-aarch64:latest
.PHONY: builder-shell
builder-shell:
docker exec \
-it \
nix-docker-builder-linux-aarch64 \
bash
.PHONY: builder-clean
builder-clean:
docker stop nix-docker-builder-linux-aarch64
docker rm nix-docker-builder-linux-aarch64
.PHONY: builder-ping
builder-ping:
nix store ping --store ssh://builder
.PHONY: butters-image
jimmy-image:
nix build -vv .#nixosConfigurations.jimmy.config.system.build.sdImage
.PHONY: leon-image
leon-image:
nix build -vv .#nixosConfigurations.leon.config.system.build.sdImage