nixos/services.samba-wsdd: remove with lib;
This commit is contained in:
parent
442fa2e366
commit
4174027fe9
@ -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 ];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user