diff --git a/modules/hooks.nix b/modules/hooks.nix index 93f37037..7013ade3 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -1,10 +1,10 @@ { config, lib, pkgs, ... }: let - inherit (config.pre-commit) tools settings; + inherit (config) tools settings; inherit (lib) mkOption types; in { - options.pre-commit.settings = + options.settings = { ormolu = { @@ -27,7 +27,7 @@ in }; }; - config.pre-commit.hooks = + config.hooks = { ansible-lint = { diff --git a/modules/pre-commit.nix b/modules/pre-commit.nix index bfdc5e34..05ab3a73 100644 --- a/modules/pre-commit.nix +++ b/modules/pre-commit.nix @@ -14,7 +14,7 @@ let inherit (pkgs) runCommand writeText git; - cfg = config.pre-commit; + cfg = config; hookType = types.submodule ( @@ -170,7 +170,7 @@ let ; in { - options.pre-commit = + options = { package = @@ -236,15 +236,26 @@ in readOnly = true; }; + src = + lib.mkOption { + description = '' + Root of the project. By default this will be filtered with the gitignoreSource + function later, unless rootSrc is specified. + ''; + type = lib.types.path; + }; + rootSrc = mkOption { type = types.package; description = '' The source of the project to be checked. + + This is used in the derivation that performs the check. ''; - defaultText = literalExample ''gitignoreSource config.root''; - default = gitignoreSource config.root; + defaultText = literalExample ''gitignoreSource config.src''; + default = gitignoreSource config.src; }; excludes = @@ -274,7 +285,7 @@ in config = { - pre-commit.rawConfig = + rawConfig = { repos = [ @@ -287,7 +298,7 @@ in exclude = mergeExcludes cfg.excludes; }; - pre-commit.installationScript = + installationScript = '' export PATH=$PATH:${cfg.package}/bin if ! type -t git >/dev/null; then diff --git a/nix/run.nix b/nix/run.nix index 7e85c630..88d2c88b 100644 --- a/nix/run.nix +++ b/nix/run.nix @@ -15,32 +15,18 @@ let [ ../modules/all-modules.nix { - options = - { - root = - lib.mkOption { - description = "Internal option"; - default = src; - internal = true; - readOnly = true; - type = lib.types.unspecified; - }; - }; config = { _module.args.pkgs = pkgs; - pre-commit = - { - inherit hooks excludes settings; - tools = builtinStuff.tools // tools; - }; + inherit hooks excludes settings src; + tools = builtinStuff.tools // tools; }; } ]; }; - inherit (project.config.pre-commit) installationScript; + inherit (project.config) installationScript; in -project.config.pre-commit.run // { +project.config.run // { shellHook = installationScript; }