-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (50 loc) · 1.31 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
HOSTNAME ?= $(shell hostname)
USERNAME ?= $(shell whoami)
UNAME := $(shell uname)
FAST ?= 0
TRACE ?= 0
## Default target - Switch configuration
.PHONY: switch
switch:
ifeq ($(UNAME), Darwin)
@darwin-rebuild switch --verbose $(if $(TRACE),--show-trace) --flake ".#$(HOSTNAME)"
else ifeq ($(UNAME), Linux)
@if grep -q '^NAME=NixOS' /etc/os-release; then \
sudo nixos-rebuild switch --verbose $(if $(FAST),--fast) $(if $(TRACE),--show-trace) --flake ".#$(HOSTNAME)"; \
else \
home-manager switch $(if $(TRACE),--show-trace) --flake ".#$(USERNAME)@$(HOSTNAME)"; \
fi
endif
.PHONY: fast
fast: FAST := 1
fast: switch
.PHONY: trace
trace: TRACE := 1
trace: switch
## Build config only
.PHONY: build
build:
ifeq ($(UNAME), Darwin)
@darwin-rebuild build --verbose $(if $(TRACE),--show-trace) --flake ".#$(HOSTNAME)"
else ifeq ($(UNAME), Linux)
@sudo nixos-rebuild build --verbose $(if $(TRACE),--show-trace) --flake ".#$(HOSTNAME)"
endif
## Update flake and rebuild
.PHONY: upgrade
upgrade: update switch
## Update flake
.PHONY: update
update:
@nix flake update
## Update keys for all secrets
.PHONY: updatekeys
updatekeys:
@fd 'secrets.ya?ml' -x sops updatekeys -y
## Generate ISO
.PHONY: iso
iso:
@sudo nix build .#nixosConfigurations.iso.config.system.build.isoImage
## Run garbage collection
.PHONY: gc
gc:
@sudo nh clean all