dotfiles/checks/pre-commit/modules/ip-search.nix

44 lines
834 B
Nix
Raw Normal View History

{
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;
};
}