dotfiles/checks/pre-commit/modules/ip-search.nix
magic_rb 3c40bda301
Improve git-hooks infrastructure, add ip hook
Signed-off-by: magic_rb <magic_rb@redalder.org>
2024-07-13 20:53:54 +02:00

43 lines
834 B
Nix

{
lib,
config,
inputs,
pkgs,
...
}: let
inherit
(lib)
mkIf
mkOption
types
pipe
concatStringsSep
getExe
;
cfg = config.hooks.ip-search;
in {
options.hooks.ip-search = {
permittedIpv4Addresses = mkOption {
type = with types; listOf str;
default = [];
description = ''
List of permitted IPv4 addresses that the linter will allow.
'';
};
};
config.hooks.ip-search = mkIf cfg.enable {
name = "IP search";
entry = let
permittedIpv4File = pipe cfg.permittedIpv4Addresses [
(concatStringsSep "\n")
(pkgs.writeText "allowed_ipv4.txt")
];
in "${getExe cfg.package} ${permittedIpv4File} .";
pass_filenames = false;
files = "";
package = inputs.self.packages.${pkgs.stdenv.system}.ip-search;
};
}