runCachixDeploy

runCachixDeploy :: AttrSet → Effect

Pushes a deploy.json to Cachix Deploy, which is a pull-based deployment service. It mediates two programs: cachix deploy activate which updates the store paths to be pulled and run by cachix deploy agent.

runCachixDeploy is a convenience function to invoke cachix deploy activate.

The cachix push <store-path> part is taken care of by configuring a cachix build cache in binary-caches.json.

Example:

runCachixDeploy {
  deploy.agents."machine1" = (pkgs.nixos ./configuration.nix).toplevel;
  async = true;
}

secrets.json:

  "default-cachix-activate": {
    "kind": "Secret",
    "data": {
      "cachixActivateToken": "....."
    }
  },
As Cachix Deploy is a new feature, make sure to use a cachix package that includes it. You can set it in an overlay or pass the package as the cachix parameter.

Parameters

deploy

The deploy.json contents as a Nix attribute set.

Example:

runCachixDeploy {
  deploy.agents = {
    "machine1" = (pkgs.nixos { ... }).toplevel;
    "machine2" = (lib.nixosSystem { ... }).config.system.build.toplevel;
  };
}
Make sure to set the correct system parameter when creating pkgs or invoking lib.nixosSystem.

secretsMap.activate

Default: "default-cachix-activate"

Name of a secret containing the cachixActivateToken field.

For example:

runCachixDeploy {
  # ...
  secretsMap.activate = "default-cachix-activate";
}

Get a Cachix Deploy activation token and replace ACTIVATION-TOKEN with it.

cd myproject
hci secret add default-cachix-activate --string cachixActivateToken ACTIVATION-TOKEN

And then copy the secret over to your Hercules CI agent secrets.json.

  "default-cachix-activate": {
    "kind": "Secret",
    "data": {
      "cachixActivateToken": "ACTIVATION-TOKEN"
    }
  },

You can generate a value for ACTIVATION-TOKEN by navigating to Cachix Deploy, creating a workspace if you haven’t already done so and clicking Start Deployment.

async

Default: false

Whether to exit immediately instead of waiting for all deployments to finish. This is useful if you are deploying to a system that might be offline, for example, a laptop.

When true, the effect will exit immediately and the deployment will continue in the background.

When false, the effect will wait for the deployment to finish before exiting. The log will be available in the Hercules CI dashboard.

If the effect will redeploy the hercules-ci-agent that runs the effect, async must be set to true.

cachix

Default: pkgs.cachix

The cachix package to use.

deployJsonFile

(Advanced use case)

The path to a deploy.json file, in case the shape of the file is not known during evaluation. Usually, deploy will suffice.

…​ — remaining arguments

Other attributes are passed to mkEffect, which passes its remaining arguments to mkDerivation.

Return value

An effect that activates the configured Cachix Deploy agents.