rules_nfpm
provides rules for building 'deb' and 'rpm' packages using NFPM, a packager written in Go.
While rules_pkg works, rules_nfpm
has the following advantages:
- Clear documentation
- No host dependencies (e.g.
rpmbuild
is not needed inPATH
) - Built-in templating of Bazel workspace status key-value pairs
Include the following snippet in your repository's WORKSPACE file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_github_ericnorris_rules_nfpm",
sha256 = "800ebc64eac94d5ec6589e98a904c8c13aaad1ae0a981550de47a5ad7f72c660",
urls = [
"https://github.com/ericnorris/rules_nfpm/archive/v2.0.0.tar.gz",
],
strip_prefix = "rules_nfpm-2.0.0",
)
load("@com_github_ericnorris_rules_nfpm//nfpm:repositories.bzl", "rules_nfpm_dependencies")
rules_nfpm_dependencies()
load("@com_github_ericnorris_rules_nfpm//nfpm:setup.bzl", "rules_nfpm_setup")
rules_nfpm_setup()
load("@com_github_ericnorris_rules_nfpm//nfpm:go_repositories.bzl", "rules_nfpm_go_dependencies")
rules_nfpm_go_dependencies()
nfpm_package(name, config, deps)
Generates a package using NFPM.
The config file is templatized using the go
text/template library. The dot (.
) value is a ConfigTemplateData struct.
nfpm_package(
name = "helloworld.deb",
config = "helloworld.yaml",
deps = [
"//cmd/helloworld",
],
)
See the example directory for a more comprehensive example.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
config | NFPM configuration file template. | Label | required | |
deps | Dependencies for this target. The output path of each dependency will be available in the .Dependencies map in the configuration file template, keyed by the dependency's label. |
List of labels | optional | [] |