Skip to content

humphrej/rules_dhall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rules_dhall

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.

Rule reference

dhall_library

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.

dhall_yaml / dhall_json

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

Command targets

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

Usage with dhall-kubernetes

It is possible to use these rules in combination with dhall-kubernetes. See example k8s.

Note on freezing dependencies

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.

Note on hashing

To find the hash for a given package/tar:

$ bazel run //rules:dhall-hash -- <path to tarfile>

About

Bazel rules to build dhall configurations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published