summary refs log tree commit diff
path: root/nixos/modules/config/networking.nix
diff options
context:
space:
mode:
authorValentin Shirokov <regellosigkeitsaxiom@yandex.ru>2017-07-08 23:04:47 +0300
committerValentin Shirokov <regellosigkeitsaxiom@yandex.ru>2017-07-08 23:04:47 +0300
commit396db6493d63352394d0f94cf8d939de637517d7 (patch)
tree6317ab29a8862033c4d326a83b1fb9886268bf2c /nixos/modules/config/networking.nix
parentca54c3f1aaea5b2a32c9add3e1b619066a46e29a (diff)
downloadnixlib-396db6493d63352394d0f94cf8d939de637517d7.tar
nixlib-396db6493d63352394d0f94cf8d939de637517d7.tar.gz
nixlib-396db6493d63352394d0f94cf8d939de637517d7.tar.bz2
nixlib-396db6493d63352394d0f94cf8d939de637517d7.tar.lz
nixlib-396db6493d63352394d0f94cf8d939de637517d7.tar.xz
nixlib-396db6493d63352394d0f94cf8d939de637517d7.tar.zst
nixlib-396db6493d63352394d0f94cf8d939de637517d7.zip
Style adjustments
Also dangerous typo fix
Diffstat (limited to 'nixos/modules/config/networking.nix')
-rw-r--r--nixos/modules/config/networking.nix16
1 files changed, 7 insertions, 9 deletions
diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix
index 7065368f7153..d0e5b35e42e8 100644
--- a/nixos/modules/config/networking.nix
+++ b/nixos/modules/config/networking.nix
@@ -213,16 +213,14 @@ in
         "hosts".text =
           let oneToString = set : ip : ip + " " + concatStringsSep " " ( getAttr ip set );
               allToString = set : concatStringsSep "\n" ( map ( oneToString set ) ( builtins.attrNames set ));
-              userLocalHosts =
-                if builtins.hasAttr "127.0.0.1" cfg.hosts
-                then concatStringsSep " " ( filter (x : x != "localhost" ) ( getAttr "127.0.0.1" cfg.hosts))
-                else "";
-              userLocalHosts6 =
-                if builtins.hasAttr "::1" cfg.hosts
-                then concatStringsSep " " ( filter (x : x != "localhost" ) ( getAttr "::1" cfg.hosts))
-                else "";
+              userLocalHosts = optionalString
+                ( builtins.hasAttr "127.0.0.1" cfg.hosts )
+                ( concatStringsSep " " ( filter (x : x != "localhost" ) ( getAttr "127.0.0.1" cfg.hosts)));
+              userLocalHosts6 = optionalString
+                ( builtins.hasAttr "::1" cfg.hosts )
+                ( concatStringsSep " " ( filter (x : x != "localhost" ) ( getAttr "::1" cfg.hosts)));
               otherHosts = allToString ( removeAttrs cfg.hosts [ "127.0.0.1" "::1" ]);
-              maybeFQDN = if cfg.fqdn == null then "" else cfq.fqdn;
+              maybeFQDN = optionalString ( cfg.fqdn != null ) cfg.fqdn;
           in
           ''
             127.0.0.1 ${maybeFQDN} ${userLocalHosts} localhost