2020-09-25 04:45:31 +00:00
|
|
|
/*
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
This file is for options that NixOS and nix-darwin have in common.
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
Platform-specific code is in the respective default.nix files.
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
*/
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
{ config, lib, options, pkgs, ... }:
|
|
|
|
let
|
2021-02-13 14:23:35 +00:00
|
|
|
inherit (lib)
|
|
|
|
filterAttrs
|
2021-10-06 13:57:05 +00:00
|
|
|
literalExpression
|
2021-02-13 14:23:35 +00:00
|
|
|
mkIf
|
|
|
|
mkOption
|
|
|
|
mkRemovedOptionModule
|
|
|
|
mkRenamedOptionModule
|
|
|
|
types
|
2024-01-02 11:29:13 +00:00
|
|
|
mkPackageOption
|
2023-05-24 13:37:59 +00:00
|
|
|
;
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
cfg = config.services.hercules-ci-agent;
|
2021-02-13 14:23:35 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
inherit (import ./settings.nix { inherit pkgs lib; }) format settingsModule;
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
2021-02-13 14:23:35 +00:00
|
|
|
(mkRenamedOptionModule [ "services" "hercules-ci-agent" "extraOptions" ] [ "services" "hercules-ci-agent" "settings" ])
|
|
|
|
(mkRenamedOptionModule [ "services" "hercules-ci-agent" "baseDirectory" ] [ "services" "hercules-ci-agent" "settings" "baseDirectory" ])
|
|
|
|
(mkRenamedOptionModule [ "services" "hercules-ci-agent" "concurrentTasks" ] [ "services" "hercules-ci-agent" "settings" "concurrentTasks" ])
|
|
|
|
(mkRemovedOptionModule [ "services" "hercules-ci-agent" "patchNix" ] "Nix versions packaged in this version of Nixpkgs don't need a patched nix-daemon to work correctly in Hercules CI Agent clusters.")
|
2020-09-25 04:45:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
options.services.hercules-ci-agent = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-09-25 04:45:31 +00:00
|
|
|
Enable to run Hercules CI Agent as a system service.
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
[Hercules CI](https://hercules-ci.com) is a
|
2020-09-25 04:45:31 +00:00
|
|
|
continuous integation service that is centered around Nix.
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
Support is available at [help@hercules-ci.com](mailto:help@hercules-ci.com).
|
2020-09-25 04:45:31 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "hercules-ci-agent" { };
|
2020-09-25 04:45:31 +00:00
|
|
|
settings = mkOption {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
These settings are written to the `agent.toml` file.
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
Not all settings are listed as options, can be set nonetheless.
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
For the exhaustive list of settings, see <https://docs.hercules-ci.com/hercules-ci/reference/agent-config/>.
|
2020-09-25 04:45:31 +00:00
|
|
|
'';
|
|
|
|
type = types.submoduleWith { modules = [ settingsModule ]; };
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Internal and/or computed values.
|
|
|
|
|
|
|
|
These are written as options instead of let binding to allow sharing with
|
|
|
|
default.nix on both NixOS and nix-darwin.
|
2021-12-06 16:07:01 +00:00
|
|
|
*/
|
2020-09-25 04:45:31 +00:00
|
|
|
tomlFile = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
internal = true;
|
2023-05-24 13:37:59 +00:00
|
|
|
defaultText = lib.literalMD "generated `hercules-ci-agent.toml`";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-09-25 04:45:31 +00:00
|
|
|
The fully assembled config file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-05-24 13:37:59 +00:00
|
|
|
# Make sure that nix.extraOptions does not override trusted-users
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion =
|
|
|
|
(cfg.settings.nixUserIsTrusted or false) ->
|
|
|
|
builtins.match ".*(^|\n)[ \t]*trusted-users[ \t]*=.*" config.nix.extraOptions == null;
|
|
|
|
message = ''
|
|
|
|
hercules-ci-agent: Please do not set `trusted-users` in `nix.extraOptions`.
|
|
|
|
|
|
|
|
The hercules-ci-agent module by default relies on `nix.settings.trusted-users`
|
|
|
|
to be effectful, but a line like `trusted-users = ...` in `nix.extraOptions`
|
|
|
|
will override the value set in `nix.settings.trusted-users`.
|
|
|
|
|
|
|
|
Instead of setting `trusted-users` in the `nix.extraOptions` string, you should
|
|
|
|
set an option with additive semantics, such as
|
|
|
|
- the NixOS option `nix.settings.trusted-users`, or
|
|
|
|
- the Nix option in the `extraOptions` string, `extra-trusted-users`
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
nix.extraOptions = ''
|
2020-09-25 04:45:31 +00:00
|
|
|
# A store path that was missing at first may well have finished building,
|
|
|
|
# even shortly after the previous lookup. This *also* applies to the daemon.
|
|
|
|
narinfo-cache-negative-ttl = 0
|
|
|
|
'';
|
2021-05-20 23:08:51 +00:00
|
|
|
services.hercules-ci-agent = {
|
|
|
|
tomlFile =
|
|
|
|
format.generate "hercules-ci-agent.toml" cfg.settings;
|
2023-05-24 13:37:59 +00:00
|
|
|
settings.config._module.args = {
|
|
|
|
packageOption = options.services.hercules-ci-agent.package;
|
|
|
|
inherit pkgs;
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
};
|
2020-09-25 04:45:31 +00:00
|
|
|
};
|
|
|
|
}
|