Skip to content

feat: expose extendModules to allow for module overrides#719

Open
michaelvanstraten wants to merge 1 commit into
cachix:masterfrom
michaelvanstraten:expose-extend-modules
Open

feat: expose extendModules to allow for module overrides#719
michaelvanstraten wants to merge 1 commit into
cachix:masterfrom
michaelvanstraten:expose-extend-modules

Conversation

@michaelvanstraten

Copy link
Copy Markdown
Contributor

This allows us to do something like this:

rec {
  pre-commit-check = git-hooks.lib.run {
    src = ./.;

    hooks = {
      nixfmt.enable = true;

      # Bash
      shellcheck = {
        enable = true;
        excludes = [ ".envrc" ];
      };
      shfmt.enable = true;
    };
  };

  pre-commit-check-without-shfmt = pre-commit-check.extendModules {
    modules = [({lib, ...} { hooks.shfmt.enable = lib.mkForce false; })]
  };
}

I personally use it to switch between which opentofu package I use (in the flake formatter attribute I need a opentofu package without any nix supplied plugins while I do need them in the flake check because of sandboxing).

This allows us to do something like this:

```nix
rec {
  pre-commit-check = git-hooks.lib.run {
    src = ./.;

    hooks = {
      nixfmt.enable = true;

      # Bash
      shellcheck = {
        enable = true;
        excludes = [ ".envrc" ];
      };
      shfmt.enable = true;
    };
  };

  pre-commit-check-without-shfmt = pre-commit-check.extendModules {
    modules = [({lib, ...} { hooks.shfmt.enable = lib.mkForce false; })]
  };
}
```

I personally use it to switch between which `opentofu` package I use
(in the flake `formatter` attribute I need a opentofu package without
any nix supplied plugins while I do need them in the flake check
because of sandboxing).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant