Skip to content

dnf

The dnf module offers pseudo-declarative package and repository management using dnf5.

This module is capable of:

  • Repository Management
    • Enabling/disabling COPR repos
    • Adding repo files via url or local files
    • Removing repos by specifying the repo name
    • Automatically cleaning up any repos added in the module
    • Adding keys for repos via url or local files
    • Adding non-free repos like rpmfusion and negativo17
  • Package Management
    • Installing packages from RPM urls, local RPM files, or package repositories
    • Installing packages from a specific repository
    • Removing packages
    • Replacing installed packages with versions from another repository
  • Optfix
    • Setup symlinks to /opt/ to allow certain packages to install
  • Add repos from
    • any https:// or http:// URL
    • any .repo files located in ./files/dnf/ of your image repo
  • If the OS version is included in the file name or URL, you can substitute it with the %OS_VERSION% magic string
    • The version is gathered from the VERSION_ID field of /usr/lib/os-release
type: dnf
repos:
files:
- https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
- custom-file.repo # file path for /files/dnf/custom-file.repo
  • COPR contains software repositories maintained by fellow Fedora users
  • The chroot can be specified for the repo. The chroot is basically the OS in which the package was built.
type: dnf
repos:
copr:
- atim/starship
- name: trixieua/mutter-patched
chroot: fedora-42-x86_64
type: dnf
repos:
files:
add:
- repo1
- repo2
remove:
- repo3
copr:
enable:
- ryanabx/cosmic-epoch
- name: trixieua/mutter-patched
chroot: fedora-42-x86_64
disable:
- kylegospo/oversteer
type: dnf
repos:
keys:
- https://example.com/repo-1.asc
- key2.asc

This allows you to add a commonly used non-free repository. You can choose between negativo17 and rpmfusion. Your choice will also disable the opposite repository if it was already enabled.

type: dnf
repos:
nonfree: negativo17

There is currently only one option that can be specified in the repository management section.

  • cleanup automatically cleans up repositories added in this section
    • Disabled by default
type: dnf
repos:
cleanup: true
type: dnf
install:
packages:
- package-1
- package-2

Optionally prevent packages from being installed. This is useful when a package pulls in another package as a dependency that you don’t want to install.

type: dnf
install:
packages:
- niri
exclude:
- alacritty
- waybar
- fuzzel
  • If the OS version is included in the file name or URL, you can substitute it with the %OS_VERSION% magic string
    • The version is gathered from the VERSION_ID field of /usr/lib/os-release
type: dnf
install:
packages:
- https://example.com/package-%OS_VERSION%.rpm
- custom-file.rpm # install files/dnf/custom-file.rpm from the image repository
  • Set repo to the name of the RPM repository, not the name or URL of the repo file
type: dnf
install:
packages:
- repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
packages:
- package-1
  • See list of all package groups by running dnf5 group list --hidden on a live system
  • Set the option with-optional to true to enable installation of optional packages in package groups
type: dnf
group-install:
with-optional: true
packages:
- de-package-1
- wm-package-2
  • You can specify one or more packages that will be swapped from another repo
  • This process uses distro-sync to perform this operation
  • All packages not specifying old: and new: will be swapped in a single transaction
type: dnf
replace:
- from-repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
packages:
- package-1
  • If a package has a different name in another repo, you can use the old: and new: properties
  • This process uses swap to perform this operation for each set
  • This process is ran before distro-sync
type: dnf
replace:
- from-repo: repo-1
packages:
- old: old-package-2
new: new-package-2

The following options can specified in the package installation, group installation, and package replacement sections.

  • install-weak-deps enables installation of the weak dependencies of RPMs
  • skip-unavailable enables skipping packages unavailable in repositories without erroring out
  • skip-broken enables skipping broken packages without erroring out
  • allow-erasing allows removing packages in case of dependency problems during package installation
  • exclude allows excluding packages from being installed during package installation
    • Empty by default
    • Corresponds to the --exclude flag
type: dnf
install:
skip-unavailable: true
exclude:
...
packages:
...
group-install:
skip-broken: true
exclude:
...
packages:
...
replace:
- from-repo: repo-1
allow-erasing: true
exclude:
...
packages:
...
  • You can set the auto-remove option to false to only remove the specific package and leave unused dependencies
type: dnf
remove:
auto-remove: false
packages:
- package-1
- package-2
type: dnf
group-remove:
packages:
- de-package-2

Optfix was an option that existed to allow installation of programs into /opt/ at build-time. With BlueBuild CLI version v0.9.23 and above, this fix happens automatically. The option is now deprecated and does nothing

This documentation page uses the installation of the Brave Browser as an example of a package that required a custom repository and a custom key to install properly. This is not an official endorsement of the Brave Browser by the BlueBuild project.

type: dnf
repos:
cleanup: true # clean up added repos after module is done
files:
- https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
- fury.repo
copr:
- atim/starship
- trixieua/mutter-patched
keys:
- https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
nonfree: rpmfusion
install:
skip-unavailable: true # skip unavailable packages
packages:
- repo: brave-browser
packages:
- brave-browser
- starship
- https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.rpm
- kubectl.rpm
exclude:
- alacritty
remove:
packages:
- firefox
- firefox-langpacks
replace:
- from-repo: copr:copr.fedorainfracloud.org:trixieua:mutter-patched
skip-unavailable: true # skip unavailable packages
packages:
- mutter
- mutter-common
- gdm
group-install:
with-optional: true # install optional packages from group
packages:
- cosmic-desktop
- cosmic-desktop-apps
- window-managers
group-remove:
packages:
- development-tools

object

boolean

Cleans up the repos added in the same step after packages are installed.

enum with valid values:

  • array of string

  • object

    • add[]: array of string List of repo files/URLs to add.

    • remove[]: array of string List of repos to disable. This must be the ID of the repo as seen in dnf5 repolist.

List of paths or URLs to .repo files to import

enum with valid values:

  • array of enum with valid values:

    • string

    • object

      • name: string The COPR repo’s name

      • chroot: string The chroot for the COPR repo

  • object

    • enable[]: array of enum with valid values:

      • string

      • object

        • name: string The COPR repo’s name

        • chroot: string The chroot for the COPR repo List of COPR repos to enable

    • disable[]: array of string List of COPR repos to disable

List of COPR project repos to add. You can also specify 2 lists instead to ‘enable’ or ‘disable’ COPR repos.

array of string

List of links to key files to import for installing from custom repositories.

enum with valid values:

  • negativo17

  • rpmfusion

Enable one of the nonfree repos.

This allows you to enable one of the nonfree repos. However, only one can be enabled at a time so if one is enabled, the other will be disabled if it is already enabled.

List of links to .repo files to download into /etc/yum.repos.d/.

array of string

DEPRECATED: List of folder names under /opt/ to enable for installing into.

object

array of string

List of RPM groups to remove.

Configuration of RPM groups removal.

object

array of string

List of RPM groups to install.

boolean

Include optional packages from group.

boolean

Whether to install weak dependencies.

boolean

Whether to continue with the install if there are no packages available in the repository.

boolean

Whether to continue with the install if there are broken packages.

boolean

Whether to allow erasing (removal) of packages in case of dependency problems.

array of string

A list of packages to prevent from being installed

Configuration of RPM groups install.

object

array of string

List of RPM packages to remove.

boolean

Whether to remove unused dependencies during removal operation.

Configuration of RPM packages removal.

object

array of enum with valid values:

  • string

  • object

    • repo: string The repo to use when installing packages

    • packages[]: array of string List of RPM packages to install.

    • install-weak-deps: boolean Whether to install weak dependencies.

    • skip-unavailable: boolean Whether to continue with the install if there are no packages available in the repository.

    • skip-broken: boolean Whether to continue with the install if there are broken packages.

    • allow-erasing: boolean Whether to allow erasing (removal) of packages in case of dependency problems.

    • exclude[]: array of string A list of packages to prevent from being installed

List of RPM packages to install.

boolean

Whether to install weak dependencies.

boolean

Whether to continue with the install if there are no packages available in the repository.

boolean

Whether to continue with the install if there are broken packages.

boolean

Whether to allow erasing (removal) of packages in case of dependency problems.

array of string

A list of packages to prevent from being installed

Configuration of RPM packages install.

array of object

string

URL to the source COPR repo for the new packages.

array of enum with valid values:

  • string

  • object

    • old: string The package to be replaced.

    • new: string The package to replace with.

    • allow-erasing: boolean Whether to allow erasing (removal) of packages in case of dependency problems.

List of packages to replace using packages from the defined repo.

boolean

Whether to install weak dependencies.

boolean

Whether to continue with the install if there are no packages available in the repository.

boolean

Whether to continue with the install if there are broken packages.

boolean

Whether to allow erasing (removal) of packages in case of dependency problems.

array of string

A list of packages to prevent from being installed

List of configurations for replacing packages from another repo.