{ lib, soonixSubmodule, pipelineSubmodule, pkgs, ... }: let inherit (lib) mkOption types foldr mapAttrsToList concatLists; in rec { 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; }; }; }; nixCiSubmodule = {config, ...}: { imports = [(pkgs.path + /nixos/modules/misc/assertions.nix)]; options = { 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; }); 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 = { # Propagate pipeline assertions to the root level assertions = concatLists ( mapAttrsToList (_name: pipeline: pipeline.assertions) config.pipelines ); packages = foldr (pipeline: acc: acc // pipeline) {} ( map (pipeline: pipeline.packages) (builtins.attrValues config.pipelines) ); soonix = config.config.soonix.finalConfig; }; }; }