-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuno.sh
90 lines (75 loc) · 1.82 KB
/
uno.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
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
#!/usr/bin/env bash
set -e
help() {
cat << EOF
uno - declarative development processes with Nix
Usage:
uno [OPTS] COMMAND [CONFIG]
Options:
--root DIR
Path to the directory containing a flake.nix with
an uno configuration. Defaults to current working
directory. Can also be set with the UNO_ROOT
environment variable.
-m, --formation process=num[,...]
The number of processes to run.
--offline
Passes the --offline flag to nix when building.
Commands:
start [CONFIG]
Starts the specified configuration, or the default
configuration if none is provided.
EOF
}
ROOT="${UNO_ROOT-$PWD}"
ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
--offline)
OFFLINE=1
shift
;;
--root)
ROOT="$2"
shift
shift
;;
-m|--formation)
FORMATION="$2"
shift
shift
;;
--help|-h)
help
exit 0
;;
-*|--*)
echo "Unknown option $1"
help
exit 1
;;
*)
ARGS+=("$1")
shift
esac
done
set -- "${ARGS[@]}"
case $1 in
start)
CONFIG_NAME="${2-default}"
SYSTEM="$(nix eval --impure --expr builtins.currentSystem)"
PROCFILE_URL="path:$ROOT#unoConfigurations.$SYSTEM.$CONFIG_NAME.procfile"
nix build ${OFFLINE:+--offline} --out-link "$ROOT/.uno/$CONFIG_NAME/Procfile" $PROCFILE_URL
PROCFILE_PATH="$(nix path-info $PROCFILE_URL)"
foreman start --root="$ROOT" --procfile="$PROCFILE_PATH" ${FORMATION:+--formation=$FORMATION}
;;
help)
help
exit 0
;;
*)
echo "Unknown command $1"
help
exit 1
;;
esac