From 4174027fe9e7521b4d6c38d4a45deb418d3fa85a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Wed, 28 Aug 2024 21:18:59 +0200 Subject: [PATCH] nixos/services.samba-wsdd: remove `with lib;` --- .../network-filesystems/samba-wsdd.nix | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/nixos/modules/services/network-filesystems/samba-wsdd.nix b/nixos/modules/services/network-filesystems/samba-wsdd.nix index f46bf802511a..60ede5a1bda2 100644 --- a/nixos/modules/services/network-filesystems/samba-wsdd.nix +++ b/nixos/modules/services/network-filesystems/samba-wsdd.nix @@ -1,65 +1,62 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.samba-wsdd; in { options = { services.samba-wsdd = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' Web Services Dynamic Discovery host daemon. This enables (Samba) hosts, like your local NAS device, to be found by Web Service Discovery Clients like Windows ''; - interface = mkOption { - type = types.nullOr types.str; + interface = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "eth0"; description = "Interface or address to use."; }; - hoplimit = mkOption { - type = types.nullOr types.int; + hoplimit = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; example = 2; description = "Hop limit for multicast packets (default = 1)."; }; - openFirewall = mkOption { + openFirewall = lib.mkOption { description = '' Whether to open the required firewall ports in the firewall. ''; default = false; type = lib.types.bool; }; - workgroup = mkOption { - type = types.nullOr types.str; + workgroup = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "HOME"; description = "Set workgroup name (default WORKGROUP)."; }; - hostname = mkOption { - type = types.nullOr types.str; + hostname = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "FILESERVER"; description = "Override (NetBIOS) hostname to be used (default hostname)."; }; - domain = mkOption { - type = types.nullOr types.str; + domain = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = "Set domain name (disables workgroup)."; }; - discovery = mkOption { - type = types.bool; + discovery = lib.mkOption { + type = lib.types.bool; default = false; description = "Enable discovery operation mode."; }; - listen = mkOption { - type = types.str; + listen = lib.mkOption { + type = lib.types.str; default = "/run/wsdd/wsdd.sock"; description = "Listen on path or localhost port in discovery mode."; }; - extraOptions = mkOption { - type = types.listOf types.str; + extraOptions = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "--shortlog" ]; example = [ "--verbose" "--no-http" "--ipv4only" "--no-host" ]; description = "Additional wsdd options."; @@ -67,7 +64,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.wsdd ]; @@ -79,13 +76,13 @@ in { DynamicUser = true; Type = "simple"; ExecStart = '' - ${pkgs.wsdd}/bin/wsdd ${optionalString (cfg.interface != null) "--interface '${cfg.interface}'"} \ - ${optionalString (cfg.hoplimit != null) "--hoplimit '${toString cfg.hoplimit}'"} \ - ${optionalString (cfg.workgroup != null) "--workgroup '${cfg.workgroup}'"} \ - ${optionalString (cfg.hostname != null) "--hostname '${cfg.hostname}'"} \ - ${optionalString (cfg.domain != null) "--domain '${cfg.domain}'"} \ - ${optionalString cfg.discovery "--discovery --listen '${cfg.listen}'"} \ - ${escapeShellArgs cfg.extraOptions} + ${pkgs.wsdd}/bin/wsdd ${lib.optionalString (cfg.interface != null) "--interface '${cfg.interface}'"} \ + ${lib.optionalString (cfg.hoplimit != null) "--hoplimit '${toString cfg.hoplimit}'"} \ + ${lib.optionalString (cfg.workgroup != null) "--workgroup '${cfg.workgroup}'"} \ + ${lib.optionalString (cfg.hostname != null) "--hostname '${cfg.hostname}'"} \ + ${lib.optionalString (cfg.domain != null) "--domain '${cfg.domain}'"} \ + ${lib.optionalString cfg.discovery "--discovery --listen '${cfg.listen}'"} \ + ${lib.escapeShellArgs cfg.extraOptions} ''; # Runtime directory and mode RuntimeDirectory = "wsdd"; @@ -121,7 +118,7 @@ in { }; }; - networking.firewall = mkIf cfg.openFirewall { + networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ 5357 ]; allowedUDPPorts = [ 3702 ]; };