hcl

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package hcl is an HCL2 front-end for pkgx pantry recipes. A package.hcl is decoded into the SAME pantry.Recipe as a package.yml — via the same schema validation — so a recipe written either way produces an identical build.

Example (equivalent to the curl.se package.yml):

distributable {
  url              = "https://curl.se/download/curl-{{version}}.tar.bz2"
  strip-components = 1
}
dependencies = { "openssl.org" = "^1.1", "zlib.net" = "^1.2.11" }
build {
  script = ["./configure $ARGS", "make --jobs {{ hw.concurrency }} install"]
  env    = { ARGS = ["--prefix={{prefix}}", "--with-openssl"] }
}
provides = ["bin/curl", "bin/curl-config"]

Blocks express nested maps (build, test, distributable); object attributes express maps whose keys aren't HCL identifiers (eg. "openssl.org").

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(yamlSrc []byte) ([]byte, error)

Convert turns a package.yml into package.hcl text, and refuses to return text that does not parse back into the same recipe.

The RENDERING is bottle.YAMLToHCL — the same conversion the client runs on upstream recipes as they arrive, which is what makes this command a measurement of the shipping path rather than of a copy of it. A second renderer here would drift, and the two would disagree about a recipe on the day it mattered.

What bk adds is the comparison the client cannot make. bottle checks that the HCL reads back as the same DOCUMENT; only bk has pantry.Parse, so only bk can check that it reads back as the same RECIPE — which is what a build actually consumes, and where the schema has its say.

func Parse

func Parse(src []byte, filename string) (*pantry.Recipe, error)

Parse decodes a package.hcl into a validated pantry.Recipe.

func ToMap

func ToMap(src []byte, filename string) (map[string]any, error)

ToMap parses package.hcl into the generic map[string]any document shape that a package.yml decodes to. It is bottle's reading, re-exported so a caller here need not know where the parser lives.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL