-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnixb
executable file
·51 lines (41 loc) · 1.03 KB
/
nixb
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
#!/usr/bin/env bash
set -euo pipefail
# `nix` wrapper script utilizing remote builders
flags=()
nixb_config="$( "$(git rev-parse --show-toplevel)/with_nixb" )"
if [ -z "${nixb_config}" ]; then
# don't bother proceeding when there's no configuration
exec nix "${@}"
fi
export NIX_CONFIG="${nixb_config}"
current_system="$(nix-instantiate --eval -E --json 'builtins.currentSystem' | jq -r '.')"
target_system="${current_system}"
orig_argv=( "${@}" )
while [ -n "${1:-}" ]; do
arg="${1}"
case "${arg}" in
--expr)
# Skip processing tons of text
shift
;;
--system)
shift
target_system="${1}"
;;
--store)
shift
store_path="${1}"
if ! [ "${store_path}" = "/nix/store" ] && [ "$(uname -s)" = "Darwin" ]; then
# error: building using a diverted store is not supported on this platform
flags+=(--max-jobs 0)
fi
;;
esac
shift
done
flags+=("--builders-use-substitutes")
set -- "${orig_argv[@]}"
if ! [ "${current_system}" = "${target_system}" ]; then
flags+=(--max-jobs 0)
fi
exec nix "${flags[@]}" "${@}"