This repo contains experimental rules for bazel to generate files using Dhall.
The rules use the method described by @Gabriel439 in this answer on stack overflow.
rules_dhall fetches binary releases of dhall from github - see section command targets.
This rule takes a dhall file and makes it available to other rules. The output of the rule is a tar archive that contains 3 files:
- the binary encoded, alpha normalized dhall expression (.cache/dhall)
- the dhall source file (source.dhall)
- a placeholder that includes the sha256 hash (binary.dhall)
Attribute | Description |
---|---|
name | string; required. |
entrypoint | label; required. This is name of the dhall file that contains the expression that is the entrypoint to the package. Any dhall references from another dhall package must include the sha256 hash. |
srcs | List of labels; optional. List of source files that are referenced from entrypoint. |
deps | List of labels; optional. List of dhall_library targets that this rule should depend on. |
data | List of labels; optional. The output of these targets will copied into this package so that dhall can reference them. |
verbose | bool; optional. If True, will output verbose logging to the console. |
See example abcd.
This rule runs a dhall output generator. The output of the rule is the YAML or JSON file.
Attribute | Description |
---|---|
entrypoint | label; required. This is name of the dhall file that contains the expression that is the entrypoint to the package. Any dhall references from another dhall package must include the sha256 hash. |
srcs | List of labels; optional. List of source files that are referenced from entrypoint. |
deps | List of labels; optional. List of dhall_library targets that this rule depends on. |
data | List of labels; optional. The output of these targets will copied into this package so that dhall can reference them. |
out | string; optional. Defaults to the src file prefix plus an extension of ".yaml" or ".json". |
verbose | bool; optional. If True, will output verbose logging to the console. |
args | List of string; optional. Adds additional arguments to dhall-to-yaml or dhall-to-json. |
See example abcd
To run dhall or dhall-to-yaml via bazel:
bazel run //cmds:dhall -- —help
bazel run //cmds:dhall-to-yaml -- —help
bazel run //cmds:dhall-to-json -- —help
It is possible to use these rules in combination with dhall-kubernetes. See example k8s.
rules_dhall relies on the semantic integrity checking feature of dhall. For this to work, expressions referenced from another dhall package must include the sha256 hash. See "dhall freeze" for details.
To find the hash for a given package/tar:
$ bazel run //rules:dhall-hash -- <path to tarfile>