-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
78 lines (63 loc) · 2.39 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
.PHONY: check help usage all update update-neovim
.DEFAULT: all
HOST=${HOSTNAME}
define usage
@echo "Usage:"
@echo " <default>"
@echo " config"
@echo " Requires that HOSTNAME be set. Configures that machine."
@echo " update"
@echo " Updates the flake.lock file so new versions can be installed. This includes modules."
@echo " update-neovim"
@echo " Updates the neovim module."
@echo
@echo "Anything prefixed with '_' is internal, but can be run separately if you need granular output."
endef
all: config
usage: help
help:
$(usage)
check:
ifeq (${HOST},)
@echo -e "\033[0;31mCall make with \033[1;34mHOSTNAME=your_host make config\033[0;31m instead.\033[0m"
exit 1
else
@echo -e "\033[0;32mChecks passed for ${HOST}, proceeding with build and switch\033[0m"
endif
config: check ${HOST}
@echo -e "\033[0;32mDone configuring ${HOST}\033[0m"
@echo -e "\033[0;32m Run \033[1;34mmake update && make\033[0;32m if your programs are out of date\033[0m"
# NixOS commands.
_nixos-build:
@echo -e "\033[0;33m-- Building ----------------------------\033[0m"
nix build ".#nixosConfigurations.${HOST}.config.system.build.toplevel" --impure
_nixos-switch:
@echo -e "\033[0;33m-- Switching ---------------------------\033[0m"
# Old command: sudo nixos-rebuild switch --flake ".#${HOST}"
# See https://github.com/NixOS/nixpkgs/issues/169193
nixos-rebuild --use-remote-sudo switch --flake ".#${HOST}" --impure
# nix-darwin commands.
_nix-darwin-build:
@echo -e "\033[0;33m-- Building ----------------------------\033[0m"
nix build ".#darwinConfigurations.${HOST}.system" --impure
_nix-darwin-switch:
@echo -e "\033[0;33m-- Switching ---------------------------\033[0m"
./result/sw/bin/darwin-rebuild switch --flake ".#${HOST}" --impure
_install_requirements:
@echo -e "\033[0;33m-- Installing required programs --------\033[0m"
./installers/homebrew
./installers/nix
update: update-neovim
@echo -e "\033[0;33m-- Updating ----------------------------\033[0m"
nix flake update
update-neovim:
@echo -e "\033[0;33m-- Updating (neovim) -------------------\033[0m"
nix flake update --flake ./modules/neovim
add-user:
./scripts/add_user.sh
# Machines
coucher: _install_requirements _nix-darwin-build _nix-darwin-switch
hog: _nixos-build _nixos-switch
theseus: _nixos-build _nixos-switch
nutop: _install_requirements _nix-darwin-build _nix-darwin-switch
minotaur: _install_requirements _nix-darwin-build _nix-darwin-switch