Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Adding a NixOS Host Secret

The nixos subcommand manages secrets for NixOS hosts. Each secret targets a specific host via --host.

Secret types

SubcommandSourceDelivery
sshGenerated Ed25519--file path
passwordGenerated passphrase--env + --service or --file
textPlaintext from stdin/file--env + --service
filePlaintext or existing .age--file path

SSH key

secret-manager nixos ssh \
  --name service-key \
  --host thething \
  --file /run/secrets/service-key

Passphrase (systemd env file)

secret-manager nixos password \
  --name vikunja-mailer \
  --host thething \
  --env VIKUNJA_MAILER_PASSWORD \
  --service vikunja \
  --length 48

This generates a passphrase and creates a systemd oneshot unit that writes an environment file consumed by the vikunja.service unit.

Text from stdin

secret-manager nixos text \
  --host thething \
  --env API_TOKEN \
  --service demo

File from plaintext or existing .age

# Encrypt plaintext from stdin
secret-manager nixos file \
  --name kubeconfig \
  --host thething \
  --file /etc/kubeconfig

# Adopt an existing encrypted .age file
secret-manager nixos file \
  --name kubeconfig \
  --host thething \
  --file /etc/kubeconfig \
  --from-age ./existing-kubeconfig.age