Skip to content

Commit

Permalink
Merge pull request cachix#60 from hercules-ci/simplify-options
Browse files Browse the repository at this point in the history
Simplify options
  • Loading branch information
domenkozar authored Oct 6, 2020
2 parents f21ddac + 44a5bfe commit e5ef518
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
6 changes: 3 additions & 3 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
@@ -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 =
{
Expand All @@ -27,7 +27,7 @@ in
};
};

config.pre-commit.hooks =
config.hooks =
{
ansible-lint =
{
Expand Down
23 changes: 17 additions & 6 deletions modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let

inherit (pkgs) runCommand writeText git;

cfg = config.pre-commit;
cfg = config;

hookType =
types.submodule (
Expand Down Expand Up @@ -170,7 +170,7 @@ let
;
in
{
options.pre-commit =
options =
{

package =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -274,7 +285,7 @@ in
config =
{

pre-commit.rawConfig =
rawConfig =
{
repos =
[
Expand All @@ -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
Expand Down
22 changes: 4 additions & 18 deletions nix/run.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit e5ef518

Please sign in to comment.