Codify
package-managers

apt

A reference page for the apt resource

The apt resource manages packages on Debian-based Linux systems using the APT (Advanced Package Tool) package manager. APT is the standard package manager for Ubuntu, Debian, Linux Mint, and other Debian-based distributions.

Parameters:

  • install: (array[string]) A list of packages to install using apt. Each entry is a string with the package name, optionally including a version constraint using the name=version syntax (e.g. "nodejs=20.*"). Codify adds packages that are missing and removes packages that are no longer listed.

  • update: (boolean) Whether to run apt-get update before installing packages to refresh the package index. Defaults to true. Set to false to skip the update step if you have recently refreshed your package lists.

Example usage:

Install packages by name

codify.jsonc
[
  {
    "type": "apt",
    "os": ["linux"],
    "install": [
      "curl",
      "git",
      "vim",
      "build-essential"
    ]
  }
]

Pin specific package versions

Use the name=version syntax to install a particular version. Wildcards (*) are supported.

codify.jsonc
[
  {
    "type": "apt",
    "os": ["linux"],
    "install": [
      "curl",
      "nodejs=20.*",
      "python3=3.12.*"
    ]
  }
]

Skip the update step

codify.jsonc
[
  {
    "type": "apt",
    "os": ["linux"],
    "install": [
      "jq",
      "htop"
    ],
    "update": false
  }
]

Notes:

  • The apt resource requires sudo privileges to install and remove packages. Codify handles privilege escalation automatically.
  • APT is only available on Debian-based Linux distributions. For Red Hat-based systems, use the yum or dnf resources instead.
  • The install list is stateful — Codify tracks which packages it installed and removes them when they are taken off the list. Packages installed outside of Codify are not affected.
  • Package names must match those available in your configured APT repositories. Use apt-cache search <package> to find available packages and apt-cache policy <package> to see available versions.
  • The os field should be set to ["linux"] when combining this resource with macOS-only resources in the same configuration file, so Codify only applies it on Linux systems.

On this page