diff --git a/flakeModule.nix b/flakeModule.nix index f68fa02..728da6d 100644 --- a/flakeModule.nix +++ b/flakeModule.nix @@ -13,6 +13,11 @@ }: let 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;}; configType = with lib; @@ -40,10 +45,6 @@ default = []; }; # gitlab opts - variables = mkOption { - type = types.attrs; - default = {}; - }; before_script = mkOption { type = types.listOf types.str; default = []; @@ -63,6 +64,10 @@ type = types.str; default = cfg.default-nix-image; }; + variables = mkOption { + type = types.nullOr types.attrs; + default = null; + }; when = mkOption { type = types.nullOr types.str; default = null; @@ -72,16 +77,16 @@ default = null; }; allow_failure = mkOption { - type = types.bool; - default = false; + type = types.nullOr types.bool; + default = null; }; needs = mkOption { type = types.nullOr (types.listOf types.str); default = null; }; rules = mkOption { - type = types.attrs; - default = {}; + type = types.nullOr types.attrs; + default = null; }; }; in { @@ -100,16 +105,16 @@ default = null; }; variables = mkOption { - type = types.attrs; - default = {}; + type = types.nullOr types.attrs; + default = null; }; default = mkOption { - type = types.attrs; - default = {}; + type = types.nullOr types.attrs; + default = null; }; stages = mkOption { - type = types.listOf types.str; - default = []; + type = types.nullOr (types.listOf types.str); + default = null; }; jobs = mkOption { type = types.lazyAttrsOf jobType; @@ -135,8 +140,8 @@ ++ job.before_script; }; - jobs = config.ci.jobs; - rest = builtins.removeAttrs config.ci ["jobs" "config"]; + jobs = filterAttrsRec (n: v: v != null) config.ci.jobs; + 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 # 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