diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index 516a5a7c9cdf..a90ca3797fd4 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -60,6 +60,8 @@ - [radicle-ci-broker](https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:zwTxygwuz5LDGBq255RA2CbNGrz8), runs CI for repositories in the local [Radicle](https://radicle.xyz/) node. Available as [services.radicle.ci.broker.enable](#opt-services.radicle.ci.broker.enable). +- [radicle-native-ci](https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE), an adapter for the [Radicle CI broker](https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:zwTxygwuz5LDGBq255RA2CbNGrz8), for performing CI runs locally. Available as [services.radicle.ci.adapters.native](#opt-services.radicle.ci.adapters.native.instances). + - [llama-swap](https://github.com/mostlygeek/llama-swap), a light weight transparent proxy server that provides automatic model swapping to llama.cpp's server (or any server with an OpenAI compatible endpoint). Available as [](#opt-services.llama-swap.enable). - [tuwunel](https://matrix-construct.github.io/tuwunel/), a federated chat server implementing the Matrix protocol, forked from Conduwuit. Available as [services.matrix-tuwunel](#opt-services.matrix-tuwunel.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index ebc1ac37df3f..63964a5cac56 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -505,6 +505,7 @@ ./services/continuous-integration/jenkins/default.nix ./services/continuous-integration/jenkins/job-builder.nix ./services/continuous-integration/jenkins/slave.nix + ./services/continuous-integration/radicle/adapters/native.nix ./services/continuous-integration/radicle/ci-broker.nix ./services/continuous-integration/woodpecker/agents.nix ./services/continuous-integration/woodpecker/server.nix diff --git a/nixos/modules/services/continuous-integration/radicle/adapters/native.nix b/nixos/modules/services/continuous-integration/radicle/adapters/native.nix new file mode 100644 index 000000000000..5ac5d02fbbe6 --- /dev/null +++ b/nixos/modules/services/continuous-integration/radicle/adapters/native.nix @@ -0,0 +1,141 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.radicle.ci.adapters.native; + brokerCfg = config.services.radicle.ci.broker; + + settingsFormat = pkgs.formats.yaml { }; + + enabledInstances = lib.filter (instance: instance.enable) (lib.attrValues cfg.instances); +in + +{ + meta.maintainers = with lib.maintainers; [ defelo ]; + + options.services.radicle.ci.adapters.native = { + instances = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.submodule ( + { config, name, ... }: + { + options = { + enable = lib.mkEnableOption "this radicle-native-ci instance" // { + default = true; + example = false; + }; + + name = lib.mkOption { + type = lib.types.str; + description = '' + Adapter name that is used in the radicle-ci-broker configuration. + Defaults to the attribute name. + ''; + }; + + package = lib.mkPackageOption pkgs "radicle-native-ci" { }; + + runtimePackages = lib.mkOption { + type = lib.types.listOf lib.types.package; + description = "Packages added to the adapter's {env}`PATH`."; + defaultText = lib.literalExpression '' + with pkgs; [ + bash + coreutils + curl + gawk + gitMinimal + gnused + wget + ] + ''; + }; + + settings = lib.mkOption { + type = lib.types.submodule { + freeformType = settingsFormat.type; + + options = { + state = lib.mkOption { + type = lib.types.path; + description = "Directory where per-run directories are stored."; + defaultText = lib.literalExpression ''"''${config.services.radicle.ci.broker.stateDir}/adapters/native/${config.name}"''; + }; + + log = lib.mkOption { + type = lib.types.path; + description = "File where radicle-native-ci should write the run log."; + defaultText = lib.literalExpression ''"''${config.services.radicle.ci.broker.logDir}/adapters/native/${config.name}.log"''; + }; + + base_url = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Base URL for build logs (mandatory for access from CI broker page)."; + default = null; + }; + }; + }; + description = '' + Configuration of radicle-native-ci. + See for more information. + ''; + default = { }; + }; + }; + + config = { + name = lib.mkDefault name; + + runtimePackages = with pkgs; [ + bash + coreutils + curl + gawk + gitMinimal + gnused + wget + ]; + + settings = { + state = lib.mkDefault "${brokerCfg.stateDir}/adapters/native/${config.name}"; + log = lib.mkDefault "${brokerCfg.logDir}/adapters/native/${config.name}.log"; + }; + }; + } + ) + ); + description = "radicle-native-ci adapter instances."; + default = { }; + }; + }; + + config = lib.mkIf (enabledInstances != [ ]) { + services.radicle.ci.broker.settings.adapters = lib.listToAttrs ( + map ( + instance: + lib.nameValuePair instance.name { + command = lib.getExe instance.package; + config = instance.settings; + config_env = "RADICLE_NATIVE_CI"; + env.PATH = lib.makeBinPath instance.runtimePackages; + } + ) enabledInstances + ); + + systemd.tmpfiles.settings.radicle-native-ci = lib.listToAttrs ( + map ( + instance: + lib.nameValuePair (builtins.dirOf instance.settings.log) { + d = { + user = config.users.users.radicle.name; + group = config.users.groups.radicle.name; + }; + } + ) enabledInstances + ); + }; +} diff --git a/nixos/modules/services/continuous-integration/radicle/ci-broker.nix b/nixos/modules/services/continuous-integration/radicle/ci-broker.nix index 9f428dfac92d..d2616ba32b28 100644 --- a/nixos/modules/services/continuous-integration/radicle/ci-broker.nix +++ b/nixos/modules/services/continuous-integration/radicle/ci-broker.nix @@ -103,7 +103,10 @@ in }; } ); - description = "CI adapters."; + description = '' + CI adapters. + See also the options under [services.radicle.ci.adapters](#opt-services.radicle.ci.adapters.native.instances). + ''; default = { }; };