-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.sh
47 lines (41 loc) · 913 Bytes
/
build.sh
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
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nixfmt-rfc-style git nh
CONFIG="/tmp/configuration-location"
FLAKE="flake.nix"
action="switch"
extraBuildArgs=()
while [[ $# -gt 0 ]]; do
case $1 in
--boot)
action="boot"
shift
;;
--update)
update="-u"
shift
;;
--ask)
ask="-a"
shift
;;
--builder)
extraBuildArgs+=("--build-host")
extraBuildArgs+=("$2")
shift
shift
;;
*)
echo "Unknown arg $1" >/dev/stderr
exit 1
;;
esac
done
# Save current directory into a file
[ -f "$CONFIG" ] && rm -f "$CONFIG"
printf "$PWD" > "$CONFIG"
# Generate flake.nix
[ -f "$FLAKE" ] && rm -f "$FLAKE"
nix eval --extra-experimental-features nix-command --write-to "$FLAKE" --file "genflake.nix" "$FLAKE"
nixfmt "$FLAKE"
# Build the system configuration
nh os $action . $update $ask ${extraBuildArgs[*]}