Home Explore Blog Models CI



nixpkgs

nixos/doc/manual/configuration/package-mgmt.chapter.md
4f490ac81ecfa520b19288aced28d33b8982d235f2d9078e00000003000002be
# Package Management {#sec-package-management}

This section describes how to add additional packages to your system.
NixOS has two distinct styles of package management:

-   *Declarative*, where you declare what packages you want in your
    `configuration.nix`. Every time you run `nixos-rebuild`, NixOS will
    ensure that you get a consistent set of binaries corresponding to
    your specification.

-   *Ad hoc*, where you install, upgrade and uninstall packages via the
    `nix-env` command. This style allows mixing packages from different
    Nixpkgs versions. It's the only choice for non-root users.

```{=include=} sections
declarative-packages.section.md
ad-hoc-packages.section.md
```

Chunks
56fbe1fc (1st chunk of `nixos/doc/manual/configuration/package-mgmt.chapter.md`)
Title: NixOS Package Management Styles
Summary
This section introduces package management in NixOS, detailing two distinct styles. The 'Declarative' style involves specifying packages in `configuration.nix`, with `nixos-rebuild` ensuring a consistent set of binaries. The 'Ad hoc' style uses the `nix-env` command for installing, upgrading, and uninstalling packages, supporting mixed Nixpkgs versions and being the sole option for non-root users.