Skip to content

package

The package module manages system packages. It automatically detects the host’s package manager.

package "nginx" state="present"
package "vim" state="present"
package "telnet" state="absent"
ParameterTypeDescription
(positional)stringPackage name
statestring"present" (install) or "absent" (remove)
ManagerDistributions
aptDebian, Ubuntu
dnfFedora, RHEL 8+
yumCentOS, RHEL 7
pacmanArch Linux
apkAlpine Linux
zypperopenSUSE
nixNixOS

The package manager is detected automatically based on the target host’s OS.

For installing Nix packages on non-NixOS distributions, use the nix module instead.

On NixOS, package installs into the invoking user’s profile (via nix-env), not system-wide configuration in /etc/nixos/configuration.nix. For system-wide installs, edit the NixOS configuration directly or use the nix module with an explicit profile=.

The module checks if the package is already installed (or already absent) before acting. No action is taken if the current state matches the desired state.

step "Install web stack" {
package "nginx" state="present"
package "certbot" state="present"
package "curl" state="present"
}
step "Remove unused" {
package "telnet" state="absent"
}