anchor.diff:  with lib;
   
   let
  -  cfg = config.services.namecoind;
  -
  -  namecoinConf =
  -  let
  -    useSSL = (cfg.rpcCertificate != null) && (cfg.rpcKey != null);
  -  in
  -  pkgs.writeText "namecoin.conf" ''
  +  cfg     = config.services.namecoind;
  +  dataDir = "/var/lib/namecoind";
  +  useSSL  = (cfg.rpc.certificate != null) && (cfg.rpc.key != null);
  +  useRPC  = (cfg.rpc.user != null) && (cfg.rpc.password != null);
  +
  +  listToConf = option: list:
  +    concatMapStrings (value :"${option}=${value}\n") list;
  +
  +  configFile = pkgs.writeText "namecoin.conf" (''
       server=1
       daemon=0
  -    rpcallowip=127.0.0.1
  +    txindex=1
  +    txprevcache=1
       walletpath=${cfg.wallet}
       gen=${if cfg.generate then "1" else "0"}
  -    rpcssl=${if useSSL then "1" else "0"}
  -    ${optionalString useSSL "rpcsslcertificatechainfile=${cfg.rpcCertificate}"}
  -    ${optionalString useSSL "rpcsslprivatekeyfile=${cfg.rpcKey}"}
  -    ${optionalString useSSL "rpcsslciphers=TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH"}
  -    txindex=1
  -    txprevcache=1
  -  '';
  +    ${listToConf "addnode" cfg.extraNodes}
  +    ${listToConf "connect" cfg.trustedNodes}
  +  '' + optionalString useRPC ''
  +    rpcbind=${cfg.rpc.address}
  +    rpcport=${toString cfg.rpc.port}
  +    rpcuser=${cfg.rpc.user}
  +    rpcpassword=${cfg.rpc.password}
  +    ${listToConf "rpcallowip" cfg.rpc.allowFrom}
  +  '' + optionalString useSSL ''
  +    rpcssl=1
  +    rpcsslcertificatechainfile=${cfg.rpc.certificate}
  +    rpcsslprivatekeyfile=${cfg.rpc.key}
  +    rpcsslciphers=TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH
  +  '');
   
   in
   
  
positive.code:         '';
        };
  
        rpcCertificate = mkOption {
          type = types.nullOr types.path;
          default = null;
          example = "/etc/namecoin/server.cert";
          description = ''
            Certificate file for securing RPC connections.
          '';
        };
  
        rpcKey = mkOption {
          type = types.nullOr types.path;
          default = null;
          example = "/etc/namecoin/server.pem";
          description = ''
            Key file for securing RPC connections.
          '';
        };
  
      };
  
    };
  
negative.code: 
      services.namecoind = {
  
        enable = mkEnableOption "namecoind, Namecoin client.";
  
        wallet = mkOption {
          type = types.path;
          default = "${dataDir}/wallet.dat";
          description = ''
            Wallet file. The ownership of the file has to be
            namecoin:namecoin, and the permissions must be 0640.
          '';
        };
  
  