fix(gitlab-ci-config): filter out any unset (null) values

This commit is contained in:
technofab 2024-01-14 18:13:26 +01:00
parent 77fded1940
commit ff363cb165

View file

@ -13,6 +13,11 @@
}: let }: let
cfg = config.ci.config; cfg = config.ci.config;
filterAttrsRec = pred: v:
if lib.isAttrs v
then lib.filterAttrs pred (lib.mapAttrs (path: filterAttrsRec pred) v)
else v;
subType = options: lib.types.submodule {inherit options;}; subType = options: lib.types.submodule {inherit options;};
configType = with lib; configType = with lib;
@ -40,10 +45,6 @@
default = []; default = [];
}; };
# gitlab opts # gitlab opts
variables = mkOption {
type = types.attrs;
default = {};
};
before_script = mkOption { before_script = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
@ -63,6 +64,10 @@
type = types.str; type = types.str;
default = cfg.default-nix-image; default = cfg.default-nix-image;
}; };
variables = mkOption {
type = types.nullOr types.attrs;
default = null;
};
when = mkOption { when = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
@ -72,16 +77,16 @@
default = null; default = null;
}; };
allow_failure = mkOption { allow_failure = mkOption {
type = types.bool; type = types.nullOr types.bool;
default = false; default = null;
}; };
needs = mkOption { needs = mkOption {
type = types.nullOr (types.listOf types.str); type = types.nullOr (types.listOf types.str);
default = null; default = null;
}; };
rules = mkOption { rules = mkOption {
type = types.attrs; type = types.nullOr types.attrs;
default = {}; default = null;
}; };
}; };
in { in {
@ -100,16 +105,16 @@
default = null; default = null;
}; };
variables = mkOption { variables = mkOption {
type = types.attrs; type = types.nullOr types.attrs;
default = {}; default = null;
}; };
default = mkOption { default = mkOption {
type = types.attrs; type = types.nullOr types.attrs;
default = {}; default = null;
}; };
stages = mkOption { stages = mkOption {
type = types.listOf types.str; type = types.nullOr (types.listOf types.str);
default = []; default = null;
}; };
jobs = mkOption { jobs = mkOption {
type = types.lazyAttrsOf jobType; type = types.lazyAttrsOf jobType;
@ -135,8 +140,8 @@
++ job.before_script; ++ job.before_script;
}; };
jobs = config.ci.jobs; jobs = filterAttrsRec (n: v: v != null) config.ci.jobs;
rest = builtins.removeAttrs config.ci ["jobs" "config"]; rest = filterAttrsRec (n: v: v != null) (builtins.removeAttrs config.ci ["jobs" "config"]);
# this allows us to nix build this to get all the mentioned dependencies from the binary cache # this allows us to nix build this to get all the mentioned dependencies from the binary cache
# pro: we don't have to download everything, just the deps for the current job # pro: we don't have to download everything, just the deps for the current job
# before, we just allowed pkgs inside the script string directly, but now with the ability to source this file # before, we just allowed pkgs inside the script string directly, but now with the ability to source this file