nixos/services.endlessh: remove with lib;

This commit is contained in:
Felix Buehler
2024-12-30 12:09:40 +01:00
parent cd46072e35
commit 57fa81efce
+10 -13
View File
@@ -4,18 +4,15 @@
pkgs,
...
}:
with lib;
let
cfg = config.services.endlessh;
in
{
options.services.endlessh = {
enable = mkEnableOption "endlessh service";
enable = lib.mkEnableOption "endlessh service";
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 2222;
example = 22;
description = ''
@@ -26,8 +23,8 @@ in
'';
};
extraOptions = mkOption {
type = with types; listOf str;
extraOptions = lib.mkOption {
type = with lib.types; listOf str;
default = [ ];
example = [
"-6"
@@ -39,8 +36,8 @@ in
'';
};
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to open a firewall port for the SSH listener.
@@ -48,7 +45,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.endlessh = {
description = "SSH tarpit";
requires = [ "network.target" ];
@@ -56,7 +53,7 @@ in
serviceConfig =
let
needsPrivileges = cfg.port < 1024;
capabilities = [ "" ] ++ optionals needsPrivileges [ "CAP_NET_BIND_SERVICE" ];
capabilities = [ "" ] ++ lib.optionals needsPrivileges [ "CAP_NET_BIND_SERVICE" ];
rootDirectory = "/run/endlessh";
in
{
@@ -115,5 +112,5 @@ in
networking.firewall.allowedTCPPorts = with cfg; optionals openFirewall [ port ];
};
meta.maintainers = with maintainers; [ azahi ];
meta.maintainers = with lib.maintainers; [ azahi ];
}