nFPM Documentation

repository·main·Indexed 25 days ago

https://github.com/goreleaser/nfpm

nFPM is a lightweight, zero-dependency tool and Go library for creating various package formats, serving as a modern alternative to fpm. It supports generating apk, arch linux, deb, ipk, msix, and rpm packages using a single YAML configuration file. The tool includes features for architecture mapping, package signing, and shell autocompletion for bash, fish, PowerShell, and zsh.

Tokens
11.8K
Snippets
46
Records
71
Agent score
82%

What's inside nFPM

  1. Overview of nFPM

    main
    nFPM is a simple, zero-dependency alternative to fpm for creating package formats. It is designed to be used both as a standalone binary and as a Go library, making as few assumptions as possible about the host environment.
  2. Use the nfpm CLI to package applications

    main

    nFPM is a Go-based packager that creates application packages in several formats including apk, arch, deb, ipk, msix, and rpm using a YAML configuration file.

    To use the CLI, you typically provide a configuration file and use the package command to generate the output files.

  3. Note on Templating support

    main
    nFPM does not support native templating within its configuration files. If your workflow requires templating, you must apply it externally before passing the configuration to nFPM. Recommended approaches include using envsubst, jsonnet, or other templating engines to generate the final configuration file.
  4. Understand script execution order during upgrades

    main

    When performing a package upgrade, scripts are executed in a specific sequence. Understanding this order is critical for managing state between the old and new versions of your package.

    Upgrade Execution Order:

    1. pretrans of new package (RPM only)
    2. preinstall of new package
    3. postinstall of new package
    4. preremove of old package
    5. postremove of old package
    6. posttrans of new package (RPM only)
  5. How nFPM handles architecture mapping

    main
    nFPM automatically translates architecture names between different formats to ensure compatibility across various packagers. It accepts common architecture strings used by Go (e.g., combinations of GOARCH and GOARM) or standard uname -m outputs (like x86_64 or aarch64) and converts them into the specific value required by the target package format (Debian, RPM, APK, etc.).
  6. Initialize a sample nfpm configuration file

    main

    Use the nfpm init command to generate a sample nfpm.yaml configuration file. This file serves as a template for defining how your application should be packaged into formats like RPM, Deb, APK, Arch Linux, ipk, or MSIX.

    By default, the command creates a file named nfpm.yaml in the current directory.

    nfpm init