mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2026-02-02 11:25:07 +01:00
feat: implement all (?) ci yaml keywords
This commit is contained in:
parent
e752f71dd1
commit
0cca02f442
3 changed files with 649 additions and 21 deletions
|
|
@ -4,8 +4,8 @@
|
|||
jobSubmodule,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkOption types filterAttrs mergeAttrsList mapAttrs;
|
||||
inherit (cilib.helpers) filterUnset mkUnsetOption toYaml toYamlPretty;
|
||||
inherit (lib) mkOption types filterAttrs mergeAttrsList mapAttrs mkRenamedOptionModule literalExpression;
|
||||
inherit (cilib.helpers) filterUnset unset mkUnsetOption toYaml toYamlPretty eitherWithSubOptions;
|
||||
|
||||
pipelineConfigSubmodule = {rootConfig, ...}: {
|
||||
options = {
|
||||
|
|
@ -30,19 +30,143 @@
|
|||
# GITLAB OPTIONS
|
||||
#
|
||||
gitlabOptions = {
|
||||
default = mkOption {
|
||||
type = types.submodule {
|
||||
# allow other keys aswell, maybe define them in the future? https://docs.gitlab.com/ci/yaml/#default
|
||||
freeformType = types.anything;
|
||||
options = {
|
||||
image = mkUnsetOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Default image to use for this entire pipeline.
|
||||
|
||||
!!! note
|
||||
Moved from top level to `default`: [GitLab Docs](https://docs.gitlab.com/ci/yaml/deprecated_keywords/).
|
||||
'';
|
||||
};
|
||||
services = mkUnsetOption {
|
||||
type = types.listOf types.anything;
|
||||
description = ''
|
||||
!!! note
|
||||
Moved from top level to `default`: [GitLab Docs](https://docs.gitlab.com/ci/yaml/deprecated_keywords/).
|
||||
'';
|
||||
};
|
||||
cache = mkUnsetOption {
|
||||
# could be more granular
|
||||
type = types.either (types.listOf types.attrs) types.attrs;
|
||||
description = ''
|
||||
!!! note
|
||||
Moved from top level to `default`: [GitLab Docs](https://docs.gitlab.com/ci/yaml/deprecated_keywords/).
|
||||
'';
|
||||
};
|
||||
before_script = mkUnsetOption {
|
||||
type = types.listOf types.str;
|
||||
description = ''
|
||||
!!! note
|
||||
Moved from top level to `default`: [GitLab Docs](https://docs.gitlab.com/ci/yaml/deprecated_keywords/).
|
||||
'';
|
||||
};
|
||||
after_script = mkUnsetOption {
|
||||
type = types.listOf types.str;
|
||||
description = ''
|
||||
!!! note
|
||||
Moved from top level to `default`: [GitLab Docs](https://docs.gitlab.com/ci/yaml/deprecated_keywords/).
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
# required for it to show up in the docs, but not in the config
|
||||
default = unset;
|
||||
defaultText = literalExpression "unset";
|
||||
description = ''
|
||||
Custom default values for job keywords.
|
||||
'';
|
||||
};
|
||||
include = mkUnsetOption {
|
||||
type = types.attrs;
|
||||
description = ''
|
||||
Import configuration from other YAML files.
|
||||
|
||||
[Docs](https://docs.gitlab.com/ci/yaml/#include)
|
||||
'';
|
||||
};
|
||||
stages = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
# .pre and .post always exist
|
||||
apply = val: [".pre"] ++ val ++ [".post"];
|
||||
description = ''
|
||||
The names and order of the pipeline stages.
|
||||
|
||||
[Docs](https://docs.gitlab.com/ci/yaml/#stages)
|
||||
|
||||
!!! note
|
||||
`.pre` and `.post` are added automatically.
|
||||
'';
|
||||
};
|
||||
variables = mkUnsetOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = '''';
|
||||
# default/global variables can have descriptions etc.
|
||||
type = types.attrsOf (eitherWithSubOptions types.str (types.submodule {
|
||||
options = {
|
||||
description = mkUnsetOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Use the `description` keyword to define a description for a default variable.
|
||||
'';
|
||||
};
|
||||
value = mkUnsetOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Use the `value` keyword to define a pipeline-level (default) variable’s value.
|
||||
'';
|
||||
};
|
||||
options = mkUnsetOption {
|
||||
type = types.listOf types.str;
|
||||
description = ''
|
||||
Use `options` to define an array of values that are [selectable in the UI when running a pipeline manually](https://docs.gitlab.com/ci/pipelines/#configure-a-list-of-selectable-prefilled-variable-values).
|
||||
'';
|
||||
};
|
||||
expand = mkUnsetOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Use the `expand` keyword to configure a variable to be expandable or not.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}));
|
||||
description = ''
|
||||
Define default CI/CD variables for all jobs in the pipeline.
|
||||
Supports strings or attrs as values, for more info see [here](https://docs.gitlab.com/ci/yaml/#variablesdescription).
|
||||
|
||||
[Docs](https://docs.gitlab.com/ci/yaml/#default-variables)
|
||||
'';
|
||||
};
|
||||
workflow = mkUnsetOption {
|
||||
type = types.attrs;
|
||||
description = ''
|
||||
Control what types of pipeline run.
|
||||
|
||||
[Docs](https://docs.gitlab.com/ci/yaml/#workflow)
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
_file = ./pipeline.nix;
|
||||
# from https://docs.gitlab.com/ci/yaml/#default
|
||||
imports = builtins.map (val: mkRenamedOptionModule [val] ["default" val]) [
|
||||
"after_script"
|
||||
"artifacts"
|
||||
"before_script"
|
||||
"cache"
|
||||
"hooks"
|
||||
"id_tokens"
|
||||
"image"
|
||||
"interruptible"
|
||||
"retry"
|
||||
"services"
|
||||
"tags"
|
||||
"timeout"
|
||||
];
|
||||
options =
|
||||
{
|
||||
nix = mkOption {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue