anchor.diff:      system.defaults.smb.NetBIOSName = cfg.hostName;
   
       system.activationScripts.networking.text = ''
  -      # Set defaults
         echo "configuring networking..." >&2
   
  -      ${hostName}
  +      ${setHostName}
  +      ${setNetworkServices}
       '';
   
     };
  
positive.code:       example = "myhostname";
        description = "Hostname for your machine.";
      };
    };
  
    config = {
  
negative.code: let
    cfg = config.networking;
  
    emptyList = lst: if lst != [] then lst else ["empty"];
    quoteStrings = concatMapStringsSep " " (str: "'${str}'");
  
    setHostName = optionalString (cfg.hostName != null) ''
      scutil --set ComputerName '${cfg.hostName}'
      scutil --set LocalHostName '${cfg.hostName}'
      scutil --set HostName '${cfg.hostName}'
    '';
  
    setNetworkServices = optionalString (cfg.networkservices != []) ''
      networkservices=$(networksetup -listallnetworkservices)
      ${concatMapStringsSep "\n" (srv: ''
        case "$networkservices" in
          *'${srv}'*)
            networksetup -setdnsservers '${srv}' ${quoteStrings (emptyList cfg.dns)}
            networksetup -setsearchdomains '${srv}' ${quoteStrings (emptyList cfg.search)}
            ;;
        esac
      '') cfg.networkservices}
    '';
  in
  
  