anchor.diff:        name = "elasticsearch";
         uid = config.ids.uids.elasticsearch;
         description = "Elasticsearch daemon user";
  -      home = es_home;
  -      createHome = true;
  +      home = cfg.dataDir;
       };
     };
   }
  
positive.code:       '';
        type = types.str;
      };
    };
  
    ###### implementation
  
    config = mkIf cfg.enable {
      environment.etc = [
        { source = configFile;
          target = "elasticsearch/elasticsearch.yml"; }
        { source = pkgs.writeText "logging.yml" cfg.logging;
          target = "elasticsearch/logging.yml"; }
      ];
  
      systemd.services.elasticsearch = {
        description = "Elasticsearch daemon";
        wantedBy = [ "multi-user.target" ];
        after = [ "network-interfaces.target" ];
        environment = { ES_HOME = es_home; };
        serviceConfig = {
          ExecStart = "${pkgs.elasticsearch}/bin/elasticsearch -f -Des.path.conf=/etc/elasticsearch";
          User = "elasticsearch";
        };
      };
  
      environment.systemPackages = [ pkgs.elasticsearch ];
  
negative.code: let
    cfg = config.services.elasticsearch;
  
    esConfig = ''
      network.host: ${cfg.host}
      network.port: ${toString cfg.port}
      network.tcp.port: ${toString cfg.tcp_port}
      cluster.name: ${cfg.cluster_name}
      ${cfg.extraConf}
    '';
  
    configDir = pkgs.buildEnv {
      name = "elasticsearch-config";
      paths = [
        (pkgs.writeTextDir "elasticsearch.yml" esConfig)
        (pkgs.writeTextDir "logging.yml" cfg.logging)
      ];
    };
  
  in {
  
  