diff --git a/nixos/doc/manual/release-notes/rl-2605.section.md b/nixos/doc/manual/release-notes/rl-2605.section.md index 5220d49e71e2..c632f4573dc5 100644 --- a/nixos/doc/manual/release-notes/rl-2605.section.md +++ b/nixos/doc/manual/release-notes/rl-2605.section.md @@ -110,6 +110,8 @@ - [Tdarr](https://tdarr.io), Audio/Video Library Analytics & Transcode/Remux Automation. Available as [services.tdarr](#opt-services.tdarr.enable) +- [whois](https://packages.qa.debian.org/w/whois.html), an intelligent WHOIS client. Available as `programs.whois`. + ## Backward Incompatibilities {#sec-release-26.05-incompatibilities} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3347adb1d145..7c14d24be41e 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -357,6 +357,7 @@ ./programs/wayland/wayfire.nix ./programs/wayland/wayvnc.nix ./programs/weylus.nix + ./programs/whois.nix ./programs/winbox.nix ./programs/wireshark.nix ./programs/wshowkeys.nix diff --git a/nixos/modules/programs/whois.nix b/nixos/modules/programs/whois.nix new file mode 100644 index 000000000000..e072dcf225fd --- /dev/null +++ b/nixos/modules/programs/whois.nix @@ -0,0 +1,89 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.programs.whois; + + configText = + lib.concatStringsSep "\n" ( + [ + "# Generated by NixOS." + "# See whois.conf(5) for the file format." + ] + ++ map (entry: "${entry.pattern} ${entry.server}") cfg.settings + ) + + "\n"; +in + +{ + options.programs.whois = { + enable = lib.mkEnableOption "whois, an intelligent WHOIS client"; + + package = lib.mkPackageOption pkgs "whois" { }; + + settings = lib.mkOption { + type = lib.types.listOf ( + lib.types.submodule { + options = { + pattern = lib.mkOption { + type = lib.types.str; + example = "\\.dn42$"; + description = '' + Case-insensitive extended regular expression used to match the + WHOIS object identifier. + ''; + }; + + server = lib.mkOption { + type = lib.types.str; + example = "whois.dn42"; + description = '' + WHOIS server to use when {option}`pattern` matches. + ''; + }; + }; + } + ); + default = [ ]; + example = lib.literalExpression '' + [ + { + pattern = "\\.dn42$"; + server = "whois.dn42"; + } + { + pattern = "\\-DN42$"; + server = "whois.dn42"; + } + { + pattern = "^as424242[0-9]{4}$"; + server = "whois.dn42"; + } + { + pattern = "^172\\.2[0-3]\\.[0-9]{1,3}\\.[0-9]{1,3}(/(1[56789]|2[0-9]|3[012]))?$"; + server = "whois.dn42"; + } + ] + ''; + description = '' + WHOIS configuration entries written to {file}`/etc/whois.conf`. + + Entries are written in the declared order, which matters when multiple + patterns may match the same query. + ''; + }; + + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + + environment.etc."whois.conf".text = configText; + }; + + meta.maintainers = with lib.maintainers; [ Cryolitia ]; +}