Skip to content

Option to Merge Multiple Seperate Configs #660

@JayRovacsek

Description

@JayRovacsek

Hi! As always - thanks for all of the hard work within this repo!

I wasn't sure how to better describe the issue in the title, so please ask clarifying questions if I miss anything that might help. Both within my work settings and personal projects, we leverage git-hooks extensively.
One of the use cases is to leverage github actions, with a simple nix flake check command to validate post push, that even users whom may not leverage nix, have ensured no issues with proposed changes.
With a few custom check hooks we have, the runtime is great locally where the checks are only ran on in-scope files and based on the delta, whereas in CICD the run of-course incorporates all files for the checks component and may take minutes.

I'd like to be able to merge two or more check configurations into a final artefact in terms of a shell hook; something like:

          checks = {
            foo = git-hooks.lib.${system}.run {
              src = self;
              hooks.actionlint.enable = true;
            };

            bar = git-hooks.lib.${system}.run {
              src = self;
              hooks.black.enable = true;
            };

            baz = git-hooks.lib.${system}.run {
              src = self;
              hooks.deadnix.enable = true;
            };
         };
          devShells.default = pkgs.devshell.mkShell {
            # Here, normally this would simply be set to something such as self.checks.${system}.git-hooks.shellHook
            # rather than "placeholder" - but this is where an ability to merge settings would be really useful
            devshell.startup.git-hooks.text = "placeholder";
            name = "merged-checks-shell";
            packages = self.checks.${system}.foo.enabledPackages
              ++ self.checks.${system}.bar.enabledPackages
              ++ self.checks.${system}.baz.enabledPackages;
          };

I recognise this is an edge-case scenario, and could be worked around a few ways, but would enable users to avoid writing complex wrapper functions generally at the benefit of enabling the exposure of checks in a still consistent manner locally, but enabling parallel runs within settings such as github actions (as each check could be better exposed as a target via projects such as https://github.com/nix-community/nix-github-actions)

Thanks again for this awesome repo!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions