-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
120 lines (104 loc) · 3.95 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
RED = \033[1;31m
GREEN = \033[1;32m
CLEAR = \033[0m
## Install Targets
## =============================================================================
all: system home
home: --reconfigure-home
system: --reconfigure-system
pull: --pull
clean:
@{ \
echo -e "--> [${GREEN}Jayu${CLEAR}] Cleaning build"
rm -rf ./jayu/build
}
## Tangle Targets
## =============================================================================
.ONESHELL:
--tangle-system:
@{ \
echo -e "--> [${GREEN}Jayu${CLEAR}] Building system configuration"
emacs --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "config/system.org")'
}
.ONESHELL:
--tangle-home: --tangle-emacs
@{ \
echo -e "--> [${GREEN}Jayu${CLEAR}] Building home configuration"
emacs --batch \
--eval "(require 'org)" \
--eval '(org-babel-tangle-file "config/home.org")' \
--eval '(org-babel-tangle-file "config/theming.org")'
}
.ONESHELL:
--tangle-emacs:
@{ \
echo -e "--> [${GREEN}Jayu${CLEAR}] Building emacs configuration"
}
## Configuration Targets
## =============================================================================
.ONESHELL:
--pull: --tangle-system
@{ \
GUIX_CONFIG_HOME="$${XDG_CONFIG_HOME:-$${HOME:-/home/$$USER}}/guix"
if [[ ! -d "$$GUIX_CONFIG_HOME" ]]; then
echo -e "--> [${GREEN}Jayu${CLEAR}] Creating $$GUIX_CONFIG_HOME"
mkdir -p "$$GUIX_CONFIG_HOME"
fi
echo -e "--> [${GREEN}Jayu${CLEAR}] Copying Guix channels"
mv ./jayu/build/channels.scm $$GUIX_CONFIG_HOME/channels.scm
echo -e "--> [${GREEN}Jayu${CLEAR}] Pulling Guix channels"
guix pull
echo -e "--> [${GREEN}Jayu${CLEAR}] Pulled Guix channels"
}
.ONESHELL:
--reconfigure-system: --tangle-system --remove-channels
@{ \
echo -e "--> [${GREEN}Jayu${CLEAR}] Reconfiguring Guix System"
__SYSTEM=$$(echo $${SYSTEM:-$$JAYU_SYSTEM} | tr 'A-Z' 'a-z')
if [ -z "$$__SYSTEM" ]; then
echo -e "!!! [${RED}Jayu${CLEAR}] No system set, set SYSTEM envvar and run again."
echo -e "!!! [${RED}Jayu${CLEAR}] This only needs to be used on the first setup"
echo -e "!!! [${RED}Jayu${CLEAR}] as the config will populate an envvar afterwards"
elif [ ! -f "./jayu/build/system/systems/$${__SYSTEM}.scm" ]; then
echo -e "!!! [${RED}Jayu${CLEAR}] System \"$$__SYSTEM\" is not a valid system"
echo -e "!!! [${RED}Jayu${CLEAR}] Valid systems:"
ls ./jayu/build/system/systems | \
sed -e "s/.scm//g" \
-e "s/^/`printf '!!! [${RED}Jayu${CLEAR}]'` /g"
elif sudo -E guix system -L ./ reconfigure ./jayu/build/system/systems/${SYSTEM}.scm; then
echo -e "--> [${GREEN}Jayu${CLEAR}] Finished reconfiguring Guix System"
else
echo -e "!!! [${RED}Jayu${CLEAR}] Failed reconfiguring Guix System"
fi
}
.ONESHELL:
--reconfigure-home: --tangle-home --remove-channels
@{ \
echo -e "--> [${GREEN}Jayu${CLEAR}] Reconfiguring Guix Home"
__USER=${USER}
if [ -z "$$USER" ]; then
echo -e "!!! [${RED}Jayu${CLEAR}] No user set, set USER envvar and run again."
echo -e "!!! [${RED}Jayu${CLEAR}] This should never happen as the shell should"
echo -e "!!! [${RED}Jayu${CLEAR}] populate the USER envvar."
elif [ ! -f "./jayu/build/home/users/$${__USER}.scm" ]; then
echo -e "!!! [${RED}Jayu${CLEAR}] User \"$$__USER\" is not a valid user. You can"
echo -e "!!! [${RED}Jayu${CLEAR}] build a different user by setting the USER envvar"
echo -e "!!! [${RED}Jayu${CLEAR}] Valid users:"
ls ./jayu/build/home/users | \
sed -e "s/.scm//g" \
-e "s/^/`printf '!!! [${RED}Jayu${CLEAR}]'` /g"
elif guix home -L ./ reconfigure ./jayu/build/home/users/${USER}.scm; then
echo -e "--> [${GREEN}Jayu${CLEAR}] Finished reconfiguring Guix Home"
else
echo -e "!!! [${RED}Jayu${CLEAR}] Failed reconfiguring Guix Home"
fi
}
# Remove channels.scm file to stop erroring when building system or home
.ONESHELL:
--remove-channels:
@{ \
if [[ -f ./jayu/build/channels.scm ]]; then
echo -e "--> [${GREEN}Jayu${CLEAR}] Removing unnecessary channels.scm"
rm ./jayu/build/channels.scm
fi
}