From 396db6493d63352394d0f94cf8d939de637517d7 Mon Sep 17 00:00:00 2001 From: Valentin Shirokov Date: Sat, 8 Jul 2017 23:04:47 +0300 Subject: [PATCH] Style adjustments Also dangerous typo fix --- nixos/modules/config/networking.nix | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix index 7065368f715..d0e5b35e42e 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