Skip to content

Commit

Permalink
Use enum for verbosity for alejandra hook
Browse files Browse the repository at this point in the history
  • Loading branch information
totoroot committed Sep 10, 2023
1 parent 44117e5 commit e646271
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,9 @@ in
mkOption {
type = types.package;
description = lib.mdDoc "The `alejandra` package to use.";
default = "${tools.alejandra}";
example = "pkgs.alejandra";
};
quiet =
mkOption {
type = types.bool;
description = lib.mdDoc "Hide informational messages.";
default = false;
example = true;
};
silent =
mkOption {
type = types.bool;
description = lib.mdDoc "Hide error messages.";
default = false;
example = true;
default = "${pkgs.alejandra}";
defaultText = "\${pkgs.alejandra}";
example = "\${pkgs.alejandra}";
};
threads =
mkOption {
Expand All @@ -122,6 +109,13 @@ in
default = null;
example = 8;
};
verbosity =
mkOption {
type = types.enum [ "normal" "quiet" "silent" ];
description = lib.mdDoc "Whether informational messages or all messages should be hidden or not.";
default = "normal";
example = "quiet";
};
};
deadnix =
{
Expand Down Expand Up @@ -994,14 +988,14 @@ in
let
cmdArgs =
mkCmdArgs (with settings.alejandra; [
[ check " --check" ]
[ (exclude != [ ]) " --exclude ${lib.escapeShellArgs (lib.unique exclude)}" ]
[ (quiet && ! silent) " --quiet" ]
[ silent " -qq" ]
[ (threads != null) " --threads ${toString threads}" ]
[ check "--check" ]
[ (exclude != [ ]) "--exclude ${lib.escapeShellArgs (lib.unique exclude)}" ]
[ (verbosity == "quiet") "-q" ]
[ (verbosity == "silent") "-qq" ]
[ (threads != null) "--threads ${toString threads}" ]
]);
in
"${settings.alejandra.package}/bin/alejandra${cmdArgs}";
"${settings.alejandra.package}/bin/alejandra ${cmdArgs}";
files = "\\.nix$";
};

Expand Down

0 comments on commit e646271

Please sign in to comment.