-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (57 loc) · 1.4 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
.PHONY: dry-run fmt os/dry-run os/switch switch update
NIX_FILES := $(shell find . -name '*.nix')
UNAME := $(shell uname)
ARCH := $(shell uname -m)
WSL_DISTRO := $(strip $(WSL_DISTRO_NAME))
fmt:
nixpkgs-fmt $(NIX_FILES)
update:
nix flake update
# Home manager
dry-run:
ifeq ($(UNAME), Darwin)
ifeq ($(ARCH), arm64)
# Darwin (arm64)
home-manager build --dry-run --flake '.#henry@darwin'
else ifeq ($(ARCH), x86_64)
# Darwin (x86_64)
home-manager build --dry-run --flake '.#henry@darwin-legacy'
else
$(error Unsupported architecture)
endif
else
# WSL & VM
home-manager build --dry-run --flake '.#nixos@all'
endif
switch:
ifeq ($(UNAME), Darwin)
ifeq ($(ARCH), arm64)
# Darwin (arm64)
home-manager switch --flake '.#henry@darwin'
else ifeq ($(ARCH), x86_64)
# Darwin (x86_64)
home-manager switch --flake '.#henry@darwin-legacy'
else
$(error Unsupported architecture)
endif
else
# WSL & VM
home-manager switch --flake '.#nixos@all'
endif
# NixOS
os/dry-run:
ifdef WSL_DISTRO
sudo nixos-rebuild dry-build --flake ".#wsl" --impure
else ifeq ($(UNAME), Darwin)
$(error Darwin is not supported)
else ifeq ($(UNAME), Linux)
sudo nixos-rebuild dry-build --flake ".#vm" --impure
endif
os/switch:
ifdef WSL_DISTRO
sudo nixos-rebuild switch --flake ".#wsl" --impure
else ifeq ($(UNAME), Darwin)
$(error Darwin is not supported)
else ifeq ($(UNAME), Linux)
sudo nixos-rebuild switch --flake ".#vm" --impure
endif