{ lib, soonixSubmodule, pipelineSubmodule, ... }: let inherit (lib) mkOption types foldr; in rec { autoChecksSubmodule = { options = { enable = mkOption { description = '' Auto-generate CI jobs from [`checks`](#checks). Each check becomes a job that runs `nix build .#checks..`. ''; type = types.bool; default = false; }; stage = mkOption { description = '' Stage to assign to auto-generated check jobs. ''; type = types.str; default = "test"; }; tags = mkOption { description = '' Tags to assign to auto-generated check jobs. ''; type = types.listOf types.str; default = []; }; pipeline = mkOption { description = '' Name of the pipeline to add auto-generated check jobs to. ''; type = types.str; default = "default"; }; }; }; configSubmodule = { options = { soonix = mkOption { description = '' Configure the soonix `.gitlab-ci.yml` generation. ''; type = types.submodule soonixSubmodule; default = {}; }; nixJobsByDefault = mkOption { description = '' Whether to transform all jobs to nix-configured jobs by default. If false, you need to set [`nix.enable`](#pipelinesnamejobsnamenixenable) for each job you want to be transformed. ''; type = types.bool; default = true; }; autoChecks = mkOption { description = '' Auto-generate CI jobs from flake checks. See [`config.autoChecks`](#configautochecks) for configuration options. ''; type = types.submodule autoChecksSubmodule; default = {}; }; }; }; nixCiSubmodule = {config, ...}: let system = config.system; in { options = { system = mkOption { description = '' System identifier (e.g. `"x86_64-linux"`). Used when building checks with `nix build .#checks..`. Set automatically by `flakeModule` or `cilib.mkCI`. ''; type = types.str; }; checks = mkOption { description = '' Nix flake checks to optionally auto-generate CI jobs from. Each attribute must be a derivation. The attribute name becomes the CI job name. Requires [`config.autoChecks.enable`](#configautochecksenable) to take effect. ''; type = types.attrsOf types.package; default = {}; }; config = mkOption { description = '' Configuration of Nix-GitLab-CI itself. ''; type = types.submodule configSubmodule; default = {}; }; pipelines = mkOption { description = '' Defines all pipelines. ''; type = types.attrsOf (types.submoduleWith { modules = [pipelineSubmodule]; specialArgs = { rootConfig = config.config; rootChecks = config.checks; rootAutoChecks = config.config.autoChecks; inherit system; }; }); default = {}; }; packages = mkOption { description = '' Final packages for use in CI. (readonly) ''; readOnly = true; type = types.attrsOf types.package; }; soonix = mkOption { description = '' Soonix config for generating `.gitlab-ci.yml`. (readonly) See [`config.soonix`](#configsoonix) for configuring this. ''; readOnly = true; type = types.attrs; }; }; config = { packages = foldr (pipeline: acc: acc // pipeline) {} ( map (pipeline: pipeline.packages) (builtins.attrValues config.pipelines) ); soonix = config.config.soonix.finalConfig; }; }; }