From 648620fcae21a93a86275fc87a28732f91737725 Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 21 Dec 2023 18:54:59 -0500 Subject: module: add exclude option --- module.nix | 31 ++++++++++++++++++++----------- test/module/flake.nix | 5 +++++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/module.nix b/module.nix index aa1a160..8c7cb02 100644 --- a/module.nix +++ b/module.nix @@ -7,17 +7,13 @@ workflowLib': { cfg = config.githubWorkflowGenerator; inherit - (builtins) + (lib) attrNames + concatLists elem - ; - - inherit - (lib) filter - getAttrs - mapAttrsToList mdDoc + mkIf mkOption literalExpression types @@ -25,7 +21,7 @@ workflowLib': { workflowLib = workflowLib' ( {inherit self;} - // lib.mkIf (cfg.platforms != {}) { + // mkIf (cfg.platforms != {}) { inherit (cfg) platforms; } ); @@ -63,12 +59,12 @@ workflowLib': { systems = mkOption { description = mdDoc "list of systems to build an output for"; type = types.listOf types.str; - default = builtins.attrNames cfg.platforms; + default = attrNames cfg.platforms; }; }; }; - jobs = lib.concatLists ( + unfilteredJobs = concatLists ( map ( output: workflowLib.mkMatrix ( @@ -94,6 +90,19 @@ in { default = {}; }; + exclude = mkOption { + description = mdDoc "outputs to exclude from matrix"; + type = types.listOf types.str; + default = []; + example = literalExpression '' + { + githubWorkflowGenerator.exclude = [ + "packages.x86_64-linux.foo" + ]; + } + ''; + }; + overrides = mkOption { description = mdDoc "overrides for mkMatrix args"; type = types.attrsOf (types.submodule overrides); @@ -110,6 +119,6 @@ in { }; config.flake.githubWorkflow = { - matrix.include = jobs; + matrix.include = filter (job: !builtins.elem job.attr cfg.exclude) unfilteredJobs; }; } diff --git a/test/module/flake.nix b/test/module/flake.nix index 69aa4a2..0bbbc54 100644 --- a/test/module/flake.nix +++ b/test/module/flake.nix @@ -25,6 +25,10 @@ "aarch64-darwin" ]; + githubWorkflowGenerator.exclude = [ + "packages.x86_64-linux.otherHello" + ]; + perSystem = {pkgs, ...}: { devShells.default = pkgs.mkShell { packages = [pkgs.hello]; @@ -32,6 +36,7 @@ packages = { inherit (pkgs) hello; + otherHello = pkgs.hello; default = pkgs.hello; }; }; -- cgit v1.2.3