-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
executable file
·59 lines (52 loc) · 1.38 KB
/
config.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
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# This script tries to build the home manager derivation based on the current
# hostname and username.
#
# By default the home manager configuration "user@host" is built.
# The available configuraitons are specified in flake.nix.
op=${1:-build} # build, install
host=${2:-$(hostname)}
user=${3:-$USER}
if [ -z "$user" ]; then
echo "No profile user name provided and \$USER is empty."
exit 1
elif [ -z "$host" ]; then
echo "No profile host name provied and \$HOST is empty."
exit 1
fi
if [ "$WSL_DISTRO_NAME" = "nixos" ] && [ "$(hostname)" = "Monoid" ]; then
activationPackage=".#homeConfigurations."${user}@nixos-wsl".activationPackage"
else
activationPackage=".#homeConfigurations."${user}@${host}".activationPackage"
fi
build() {
if ! nix build \
--extra-experimental-features 'nix-command flakes' \
"$activationPackage"; then
echo "Package ${activationPackage} cannot be build!"
exit 1
fi
}
case "$op" in
build)
build
;;
install)
build
if [ -x "./result/activate" ]; then
if "./result/activate"; then
echo "Successfully activated/installed package $activationPackage"
else
exit 1
fi
else
echo "./result/activate has not been generated by the build."
exit 1
fi
;;
*)
echo "Unknown operation: $op"
echo "Supported operations are: build, install"
exit 1
;;
esac