anchor.diff:      (optionalString (cfg.defaultMode == "norouting") "--routing=none")
     ] ++ cfg.extraFlags);
   
  -  defaultDataDir = if versionAtLeast config.system.stateVersion "17.09" then
  -    "/var/lib/ipfs" else
  -    "/var/lib/ipfs/.ipfs";
  -
  -  # Wrapping the ipfs binary with the environment variable IPFS_PATH set to dataDir because we can't set it in the user environment
  -  wrapped = runCommand "ipfs" { buildInputs = [ makeWrapper ]; preferLocalBuild = true; } ''
  -    mkdir -p "$out/bin"
  -    makeWrapper "${ipfs}/bin/ipfs" "$out/bin/ipfs" \
  -      --set IPFS_PATH ${cfg.dataDir} \
  -      --prefix PATH : /run/wrappers/bin
  -  '';
  -
  -
  -  commonEnv = {
  -    environment.IPFS_PATH = cfg.dataDir;
  -    path = [ wrapped ];
  -    serviceConfig.User = cfg.user;
  -    serviceConfig.Group = cfg.group;
  -  };
  -
  -  baseService = recursiveUpdate commonEnv {
  -    wants = [ "ipfs-init.service" ];
  -    preStart = optionalString cfg.autoMount ''
  -      ipfs --local config Mounts.FuseAllowOther --json true
  -      ipfs --local config Mounts.IPFS ${cfg.ipfsMountDir}
  -      ipfs --local config Mounts.IPNS ${cfg.ipnsMountDir}
  -    '' + concatStringsSep "\n" (collect
  -          isString
  -          (mapAttrsRecursive
  -            (path: value:
  -            # Using heredoc below so that the value is never improperly quoted
  -            ''
  -              read value <<EOF
  -              ${builtins.toJSON value}
  -              EOF
  -              ipfs --local config --json "${concatStringsSep "." path}" "$value"
  -            '')
  -            ({ Addresses.API = cfg.apiAddress;
  -               Addresses.Gateway = cfg.gatewayAddress;
  -               Addresses.Swarm = cfg.swarmAddress;
  -            } //
  -            cfg.extraConfig))
  -        );
  -    serviceConfig = {
  -      ExecStart = "${wrapped}/bin/ipfs daemon ${ipfsFlags}";
  -      Restart = "on-failure";
  -      RestartSec = 1;
  -    } // optionalAttrs (cfg.serviceFdlimit != null) { LimitNOFILE = cfg.serviceFdlimit; };
  -  };
   in {
   
     ###### interface
  
positive.code: 
        dataDir = mkOption {
          type = types.str;
          default = defaultDataDir;
          description = "The data dir for IPFS";
        };
  
  
negative.code:       serviceConfig = {
          Type = "oneshot";
          RemainAfterExit = true;
          User = cfg.user;
          Group = cfg.group;
        };
      };
  
      systemd.services.ipfs = {
        path = [ "/run/wrappers" pkgs.ipfs ];
        environment.IPFS_PATH = cfg.dataDir;
  
        wants = [ "ipfs-init.service" ];
        after = [ "ipfs-init.service" ];
  
        wantedBy = [ "default.target" ];
  
        preStart = optionalString cfg.autoMount ''
          ipfs --local config Mounts.FuseAllowOther --json true
          ipfs --local config Mounts.IPFS ${cfg.ipfsMountDir}
          ipfs --local config Mounts.IPNS ${cfg.ipnsMountDir}
        '' + concatStringsSep "\n" (collect
              isString
              (mapAttrsRecursive
                (path: value:
                # Using heredoc below so that the value is never improperly quoted
                ''
                  read value <<EOF
                  ${builtins.toJSON value}
                  EOF
                  ipfs --local config --json "${concatStringsSep "." path}" "$value"
                '')
                ({ Addresses.API = cfg.apiAddress;
                   Addresses.Gateway = cfg.gatewayAddress;
                   Addresses.Swarm = cfg.swarmAddress;
                } //
                cfg.extraConfig))
            );
        serviceConfig = {
          ExecStart = "${pkgs.ipfs}/bin/ipfs daemon ${ipfsFlags}";
          User = cfg.user;
          Group = cfg.group;
        } // optionalAttrs (cfg.serviceFdlimit != null) { LimitNOFILE = cfg.serviceFdlimit; };
      };
  
    };
  