-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproject-toolset-setup.envrc
52 lines (45 loc) · 1.56 KB
/
project-toolset-setup.envrc
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
# shellcheck shell=bash
# vim: filetype=direnv
# Usage:
#
# use project_toolset_setup TOOLSET_NAME DEV_DIRECTORY
function use_project_toolset_setup() {
local -r toolset="$1"; shift
local dev_dir="$1"; shift
dev_dir="$(cd "${dev_dir}" && pwd)"
local root
root="$(dirname "${dev_dir}")" # TODO: Move this to dot.envrc?
# See `README.md` for information about directory structure.
local -r config_dir="${dev_dir}/config"
local -r toolset_dev_dir="${config_dir}/${toolset}"
# Import Command Wrapper Direnv library in `.envrc`.
#
# For more information see `command-wrapper-direnv-library(7)` manual page,
# or call:
#
# ```Bash
# TOOLSET help --man direnv-library
# ```
#
# shellcheck source=/dev/null
source <("${toolset}" --no-aliases completion --library --direnv --content)
# These options are used by the toolset configuration files.
{
env root="${root}" "${toolset}" --no-aliases config --dhall \
| command_wrapper_dhall_cache "${toolset}" 'options.dhall' "${toolset_dev_dir}"
} <<< '
{ Type = { projectRoot : Text }
, default.projectRoot = env:root as Text
}
'
# Configuration files used by the toolset, that are not automatically
# tracked.
local -r -a watch_files=(
"${dev_dir}/config/${toolset}/default/exec-aliases.dhall"
"${dev_dir}/config/${toolset}/command-wrapper-exec.dhall"
)
for file in "${watch_files[@]}"; do
watch_file "${file}"
done
use command_wrapper "${toolset}" "${config_dir}"
}