Skip to content

Usage

Codify is designed around two main commands (plan and apply) and a codify.jsonc configuration file. codify plan first reads the file to determine what the final state should be. The plan command then does a query of what is currently installed/configured on the system in order to generate a plan of how to reach the desired state. codify apply then applies the changes listed in the plan onto the system.

Commands

  • plan: Generates a list of changes to meet the desired config. Dy default, plan does not store state and cannot destroy resources. This allows plan to be used without maintaining a state file or requiring resources to be imported. Use codify destroy to uninstall resources. Plan can only be called in a directory with a codify.jsonc file.
  • apply: Run a codify plan and offer the option to apply the generated plan.
  • destroy: Similar to apply but this command will attempt to destroy the listed resources. A confirmation and a plan of the list of changes will be shown.
  • import: Generates Codify configs based on what is currently on the system. This command basically does the opposite of apply.
  • init: Generates a full Codify config based on what’s already installed / configured. Useful for generating your initial Codify config file.

Config file

File typePlanApplyImport
jsonc
json
json5
yaml

The config file defines the desired system state. Users declare which resources (programs, tools, or settings) should be installed and how. The recommended file type to use is jsonc because of the support for commenting. If your editor supports it, json5 is preferred—it allows comments, multiline strings, and has more lenient syntax. YAML is supported as well but does not support config generation.

The file is a top-level array of resource objects, each with a required type and resource-specific parameters. In most IDEs with SchemaStore support, autocomplete works automatically for codify.jsonc files.

See codify.jsonc for more information.

[
{
"type": "homebrew",
"formulae": ["jq"]
},
{
"type": "vscode"
}
]

Modes

Stateless Mode

Stateless mode is the default mode for Codify. In stateless mode, packages can only be installed and modified but not uninstalled. Existing packages do not need to be imported into Codify in stateless mode and no state files are generated. When running codify apply in stateless mode, Codify will only modify existing packages to match the desired config or install new ones. If a package already exists and matches the desired config, it will be excluded from the plan.

Stateful Mode

Not released yet.

Stateful mode will allow users to manage every dependency on their system. Using stateful mode, Codify will attempt to delete packages that are removed from codify.jsonc. Stateful mode is meant to be used as an application manager.