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

(experimental) Hercules CI effects

See flake.nix for an example and the Hercules CI effects documentation for the upstream reference.

CLI usage

The nixbot-effects CLI can list and run effects locally, or against remote repositories using Nix flake references.

Local repository

$ cd my-repo
$ nixbot-effects list
["deploy", "notify"]

$ nixbot-effects run deploy

Remote repository (flake reference)

No local checkout needed:

$ nixbot-effects run github:org/repo/branch#deploy
$ nixbot-effects list github:org/repo/branch
$ nixbot-effects list-schedules github:org/repo/branch
$ nixbot-effects run-scheduled github:org/repo#flake-update update

Subcommands

CommandDescription
listList available effects
runRun a single effect
list-schedulesList scheduled effects
run-scheduledRun a specific effect from a schedule

Flags

All subcommands accept:

FlagDescription
--revGit revision to use
--branchGit branch to use
--repoGit repo name
--pathPath to the repository (default: current directory)
--debugEnable debug mode (may leak secrets such as GITHUB_TOKEN)

run and run-scheduled also accept:

FlagDescription
--secretsPath to a JSON file with secrets

Running effects locally with secrets

Pass --secrets to provide secrets when running effects locally. The file is a JSON object where each key is a secret name and its value has a "data" field containing key-value pairs:

{
  "my-secret": {
    "data": {
      "token": "ghp_xxxxxxxxxxxx",
      "username": "deploy-bot"
    }
  }
}
$ nixbot-effects run --secrets secrets.json deploy

Inside the effect, secrets are available at /run/secrets.json (via HERCULES_CI_SECRETS_JSON). This follows the hercules-ci secrets format.

Buildbot secrets configuration

When running effects through nixbot (not locally), secrets are configured at different scopes:

  1. Repository-specific: "github:owner/repo" — applies to a single repository
  2. Organization-wide: "github:org/*" — applies to all repositories in an organization
services.nixbot.effects.perRepoSecretFiles = {
  # All repos in nix-community org get this token
  "github:nix-community/*" = config.agenix.secrets.nix-community-effects.path;

  # This specific repo gets its own token (overrides org-level)
  "github:nix-community/nixbot" = config.agenix.secrets.nixbot-effects.path;

  # All repos in a Gitea org
  "gitea:my-org/*" = config.agenix.secrets.my-org-effects.path;
};

The secrets files must be valid JSON files containing the secrets that will be made available to your effects at runtime.