about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorBas van Dijk <v.dijk.bas@gmail.com>2017-04-09 01:57:32 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-04-09 11:18:53 +0200
commit01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a (patch)
tree3dcc5c646891e64860e09eb5e2180c78b5786ce0 /nixos/modules
parenta49481a7401de9e1958ea97e31856f406de99212 (diff)
downloadnixlib-01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a.tar
nixlib-01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a.tar.gz
nixlib-01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a.tar.bz2
nixlib-01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a.tar.lz
nixlib-01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a.tar.xz
nixlib-01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a.tar.zst
nixlib-01a8de97eb2aab98e6e9a7330bf99f4fe4844d2a.zip
avahi-daemon: refactored using some abstraction
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/networking/avahi-daemon.nix26
1 files changed, 13 insertions, 13 deletions
diff --git a/nixos/modules/services/networking/avahi-daemon.nix b/nixos/modules/services/networking/avahi-daemon.nix
index e7ef68c90b2a..3985f8561d35 100644
--- a/nixos/modules/services/networking/avahi-daemon.nix
+++ b/nixos/modules/services/networking/avahi-daemon.nix
@@ -7,32 +7,32 @@ let
 
   cfg = config.services.avahi;
 
+  yesNo = yes : if yes then "yes" else "no";
+
   avahiDaemonConf = with cfg; pkgs.writeText "avahi-daemon.conf" ''
     [server]
     ${# Users can set `networking.hostName' to the empty string, when getting
       # a host name from DHCP.  In that case, let Avahi take whatever the
       # current host name is; setting `host-name' to the empty string in
       # `avahi-daemon.conf' would be invalid.
-      if hostName != ""
-      then "host-name=${hostName}"
-      else ""}
+      optionalString (hostName != "") "host-name=${hostName}"}
     browse-domains=${concatStringsSep ", " browseDomains}
-    use-ipv4=${if ipv4 then "yes" else "no"}
-    use-ipv6=${if ipv6 then "yes" else "no"}
+    use-ipv4=${yesNo ipv4}
+    use-ipv6=${yesNo ipv6}
     ${optionalString (interfaces!=null) "allow-interfaces=${concatStringsSep "," interfaces}"}
     ${optionalString (domainName!=null) "domain-name=${domainName}"}
-    allow-point-to-point=${if allowPointToPoint then "yes" else "no"}
+    allow-point-to-point=${yesNo allowPointToPoint}
 
     [wide-area]
-    enable-wide-area=${if wideArea then "yes" else "no"}
+    enable-wide-area=${yesNo wideArea}
 
     [publish]
-    disable-publishing=${if publish.enable then "no" else "yes"}
-    disable-user-service-publishing=${if publish.userServices then "no" else "yes"}
-    publish-addresses=${if publish.userServices || publish.addresses then "yes" else "no"}
-    publish-hinfo=${if publish.hinfo then "yes" else "no"}
-    publish-workstation=${if publish.workstation then "yes" else "no"}
-    publish-domain=${if publish.domain then "yes" else "no"}
+    disable-publishing=${yesNo (!publish.enable)}
+    disable-user-service-publishing=${yesNo (!publish.userServices)}
+    publish-addresses=${yesNo (publish.userServices || publish.addresses)}
+    publish-hinfo=${yesNo publish.hinfo}
+    publish-workstation=${yesNo publish.workstation}
+    publish-domain=${yesNo publish.domain}
   '';
 
 in