podman

Here is a structured, document-style explanation of how to manage Podman on NixOS (based on the declarative approach we discussed earlier). This covers applying changes, checking/verifying, and uninstalling/removing it cleanly.

Podman on NixOS: Apply, Check, Verify & Uninstall Guide

Goal
Declaratively enable Podman (with Docker compatibility) via your NixOS configuration. This makes containers reproducible, auditable, and easy to manage/rollback.

1. Applying / Enabling Podman (Installation)

Edit your configuration file (usually /etc/nixos/configuration.nix or in your flake-based config folder):

Add this block (minimal recommended setup):

{ config, pkgs, ... }:

{
  virtualisation = {
    containers.enable = true;                # Creates /etc/containers/policy.json, registries.conf, etc.
    
    podman = {
      enable = true;
      
      # Makes 'docker' command alias to 'podman' (great compatibility for scripts/tools)
      dockerCompat = true;
      
      # Optional: auto-remove unused images/containers weekly
      autoPrune.enable = true;
      
      # Optional: better default network with DNS resolution inside containers
      defaultNetwork.settings.dns_enabled = true;
    };
  };

  # Optional: add useful companion tools
  environment.systemPackages = with pkgs; [
    podman-compose     # for docker-compose.yml files
    podman-tui         # nice TUI for managing containers/pods
  ];
}

Apply the changes (this is the equivalent of “installing” or “upgrading”):

sudo nixos-rebuild switch

2. Checking / Verifying Podman Works

After rebuild, verify everything is active and functional:

CheckCommandExpected Output / Meaning
Podman versionpodman --versionpodman version X.Y.Z (shows it’s in PATH)
Rootless socket activesystemctl --user status podman.socketShould be “active (listening)” (rootless is default for normal users)
Docker aliasdocker --versionShould say “podman version …” if dockerCompat = true;
Test container (rootless)podman run --rm hello-worldPrints hello message → Podman works
List running containerspodman ps or docker psShows table (empty is fine)
Config files createdls /etc/containers/See policy.json, registries.conf, storage.conf etc.
System-wide infopodman infoDetailed config, registries, store paths, etc.

If something fails:

3. Uninstalling / Removing Podman

To completely remove Podman (reverse the installation):

  1. Edit configuration.nix

    • Remove or comment out the entire virtualisation.containers.enable = true; and virtualisation.podman = { ... }; block.
    • Remove any podman-compose, podman-tui, etc. from environment.systemPackages.

    Example after removal:

    # virtualisation.containers.enable = true;          # ← commented out or deleted
    # virtualisation.podman = { ... };                  # ← removed
    
  2. Apply removal:

    sudo nixos-rebuild switch
    
    • This rebuilds the system without Podman → old generations still exist (for rollback).
    • Podman binary, socket, aliases, and /etc/containers/* files disappear from the active system.
  3. Optional: Clean up old generations & free space (after confirming everything works without Podman):

    sudo nix-collect-garbage -d          # Deletes all old generations (careful!)
    # or safer:
    sudo nix-env --delete-generations  +5   # Keeps last 5 generations
    sudo nix-collect-garbage
    
    • This removes old closures containing Podman (if no other references exist).
  4. Stop & disable user socket (if rootless was used):

    systemctl --user stop podman.socket
    systemctl --user disable podman.socket
    systemctl --user mask podman.socket   # Optional: prevent accidental restart
    

4. Where to Find What Was Installed (for SBOM or Auditing)

NixOS makes the full list of installed packages deterministic and queryable. For Software Bill of Materials (SBOM) or compliance/audit needs:

Quick human-readable list of system packages (including Podman if enabled):

# All runtime dependencies of the current system (most complete/accurate)
nix-store -q --requisites /run/current-system | xargs -n1 nix-store -q --tree | sort -u

# Simpler: top-level packages from your config
nixos-option environment.systemPackages   # shows declared ones
# or
nix eval --raw .#nixosConfigurations.$(hostname).config.environment.systemPackages   # if using flakes

For proper SBOM generation (CycloneDX / SPDX format, machine-readable, with versions, purls, hashes):

Nixpkgs doesn’t have built-in SBOM export yet (as of March 2026), but community tools work well:

These tools walk the Nix closure graph of /run/current-system (or any derivation) and produce a full dependency tree with metadata. Podman + its runtime deps (runc, conmon, slirp4netns, etc.) + any transitive libs will appear there.

Summary: SBOM sources on NixOS

This keeps your setup fully declarative, auditable, and reversible — core NixOS strengths.

If you need help integrating SBOM generation into your rebuild workflow or flake, let me know!