10 format = pkgs.formats.toml { };
12 settingsModule = { config, packageOption, pkgs, ... }: {
13 freeformType = format.type;
15 apiBaseUrl = mkOption {
17 API base URL that the agent will connect to.
19 When using Hercules CI Enterprise, set this to the URL where your
20 Hercules CI server is reachable.
23 default = "https://hercules-ci.com";
25 baseDirectory = mkOption {
27 default = "/var/lib/hercules-ci-agent";
29 State directory (secrets, work directory, etc) for agent
32 concurrentTasks = mkOption {
34 Number of tasks to perform simultaneously.
36 A task is a single derivation build, an evaluation or an effect run.
37 At minimum, you need 2 concurrent tasks for `x86_64-linux`
38 in your cluster, to allow for import from derivation.
40 `concurrentTasks` can be around the CPU core count or lower if memory is
43 The optimal value depends on the resource consumption characteristics of your workload,
44 including memory usage and in-task parallelism. This is typically determined empirically.
46 When scaling, it is generally better to have a double-size machine than two machines,
47 because each split of resources causes inefficiencies; particularly with regards
48 to build latency because of extra downloads.
50 type = types.either types.ints.positive (types.enum [ "auto" ]);
52 defaultText = lib.literalMD ''
53 `"auto"`, meaning equal to the number of CPU cores.
58 A key-value map of user data.
60 This data will be available to organization members in the dashboard and API.
62 The values can be of any TOML type that corresponds to a JSON type, but arrays
63 can not contain tables/objects due to limitations of the TOML library. Values
64 involving arrays of non-primitive types may not be representable currently.
67 defaultText = literalExpression ''
69 agent.source = "..."; # One of "nixpkgs", "flake", "override"
75 workDirectory = mkOption {
77 The directory in which temporary subdirectories are created for task state. This includes sources for Nix evaluation.
80 default = config.baseDirectory + "/work";
81 defaultText = literalExpression ''baseDirectory + "/work"'';
83 staticSecretsDirectory = mkOption {
85 This is the default directory to look for statically configured secrets like `cluster-join-token.key`.
87 See also `clusterJoinTokenPath` and `binaryCachesPath` for fine-grained configuration.
90 default = config.baseDirectory + "/secrets";
91 defaultText = literalExpression ''baseDirectory + "/secrets"'';
93 clusterJoinTokenPath = mkOption {
95 Location of the cluster-join-token.key file.
97 You can retrieve the contents of the file when creating a new agent via
98 <https://hercules-ci.com/dashboard>.
100 As this value is confidential, it should not be in the store, but
101 installed using other means, such as agenix, NixOps
102 `deployment.keys`, or manual installation.
104 The contents of the file are used for authentication between the agent and the API.
107 default = config.staticSecretsDirectory + "/cluster-join-token.key";
108 defaultText = literalExpression ''staticSecretsDirectory + "/cluster-join-token.key"'';
110 binaryCachesPath = mkOption {
112 Path to a JSON file containing binary cache secret keys.
114 As these values are confidential, they should not be in the store, but
115 copied over using other means, such as agenix, NixOps
116 `deployment.keys`, or manual installation.
118 The format is described on <https://docs.hercules-ci.com/hercules-ci-agent/binary-caches-json/>.
121 default = config.staticSecretsDirectory + "/binary-caches.json";
122 defaultText = literalExpression ''staticSecretsDirectory + "/binary-caches.json"'';
124 secretsJsonPath = mkOption {
126 Path to a JSON file containing secrets for effects.
128 As these values are confidential, they should not be in the store, but
129 copied over using other means, such as agenix, NixOps
130 `deployment.keys`, or manual installation.
132 The format is described on <https://docs.hercules-ci.com/hercules-ci-agent/secrets-json/>.
135 default = config.staticSecretsDirectory + "/secrets.json";
136 defaultText = literalExpression ''staticSecretsDirectory + "/secrets.json"'';
142 if packageOption.highestPrio == (lib.modules.mkOptionDefault { }).priority
144 else lib.mkOptionDefault "override";
145 pkgs.version = pkgs.lib.version;
146 lib.version = lib.version;
152 inherit format settingsModule;