Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ericnorris/rules_nfpm

NFPM rules for Bazel
https://github.com/ericnorris/rules_nfpm

bazel bazel-rules deb packager rpm

Last synced: about 1 month ago
JSON representation

NFPM rules for Bazel

Awesome Lists containing this project

README

        

# rules_nfpm

`rules_nfpm` provides rules for building 'deb' and 'rpm' packages using [NFPM](https://github.com/goreleaser/nfpm/), a packager written in Go.

While [rules_pkg](https://github.com/bazelbuild/rules_pkg/) _works_, `rules_nfpm` has the following advantages:

- Clear documentation
- No host dependencies (e.g. `rpmbuild` is not needed in `PATH`)
- Built-in templating of Bazel [workspace status](https://docs.bazel.build/versions/master/user-manual.html#workspace_status) key-value pairs

## Setup

Include the following snippet in your repository's WORKSPACE file:

```starlark
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


nfpm_package(name, config, deps)

Generates a package using [NFPM](https://github.com/goreleaser/nfpm/).

The config file is templatized using the `go` [text/template](https://golang.org/pkg/text/template/) library. The dot (`.`) value is a [ConfigTemplateData](https://pkg.go.dev/github.com/ericnorris/rules_nfpm/go/internal/cmd/nfpmwrapper?tab=doc#ConfigTemplateData) struct.

### Example

```starlark
nfpm_package(
name = "helloworld.deb",
config = "helloworld.yaml",
deps = [
"//cmd/helloworld",
],
)
```

See the [example directory](/example/README.md) 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 | [] |