git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

Redesign module options

Open domenkozar opened this issue 2 years ago • 3 comments

Something like:

{
  git.hooks.pre-commit.shellcheck.enable = true;
  git.hooks.push.shellcheck.enable = true;
}

cc @roberth

domenkozar avatar Nov 24 '22 13:11 domenkozar

-  git.hooks.pre-commit.shellcheck.enable = true;
+  hooks.pre-commit.shellcheck.enable = true;

This way devenv can import it using git = mkOption { type = submodule pre-commit-hooks-module; } and the flake parts module can import it in its own way. The latter needs to be explicit about the implementation in the prefix and pre-commit.settings.git.hooks would kinda suck. Isn't this the status quo actually?

Anyway, another nice thing would be to do

{
options.hooks = mkOption {
  type = submodule {
    freeformType = types.attrsOf hookModule;
  };
};
}

and then declare built in hooks as something like

{
options.hooks.nixpkgs-fmt = mkOption {
  type = submodule {
    imports = [ hookModule ];
    options.some-setting = mkOption ...;
  };
};
}

thereby adding the individual hooks in the option docs, and removing the need for a separate settings namespace.

roberth avatar Nov 24 '22 13:11 roberth

The redesigned pattern should have a package option, so the tools indirection becomes unnecessary, and overlays can be avoided. Refs https://github.com/cachix/pre-commit-hooks.nix/issues/204#issuecomment-1334165738

roberth avatar Dec 02 '22 18:12 roberth

Eventually I'd like the interface to be:

  hooks.ormolu.enable = true;
  hooks.ormolu.package = pkgs.ormolu;
  hooks.ormolu.settings.defaultExtensions = [ "lhs" "hs" ];

domenkozar avatar Feb 20 '23 09:02 domenkozar

Merged to master!

domenkozar avatar Mar 19 '24 03:03 domenkozar