anchor.diff:      };
   
       users.extraGroups = mkIf (cfg.group == "ipfs") {
  -      ipfs = {
  -        gid = config.ids.gids.ipfs;
  -      };
  -    };
  -
  -    systemd.services.ipfs-init = {
  +      ipfs.gid = config.ids.gids.ipfs;
  +    };
  +
  +    systemd.services.ipfs-init = recursiveUpdate commonEnv {
         description = "IPFS Initializer";
   
         after = [ "local-fs.target" ];
         before = [ "ipfs.service" "ipfs-offline.service" ];
  -
  -      environment.IPFS_PATH = cfg.dataDir;
  -
  -      path  = [ pkgs.ipfs pkgs.su pkgs.bash ];
   
         preStart = ''
           install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}
         '';
         script = ''
           if [[ ! -f ${cfg.dataDir}/config ]]; then
  -          ${ipfs}/bin/ipfs init ${optionalString cfg.emptyRepo "-e"}
  +          ipfs init ${optionalString cfg.emptyRepo "-e"}
           fi
  -        ${ipfs}/bin/ipfs --local config Addresses.API ${cfg.apiAddress}
  -        ${ipfs}/bin/ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}
  +        ipfs --local config Addresses.API ${cfg.apiAddress}
  +        ipfs --local config Addresses.Gateway ${cfg.gatewayAddress}
         '' + optionalString cfg.autoMount ''
  -        ${ipfs}/bin/ipfs --local config Mounts.FuseAllowOther --json true
  -        mkdir -p $(${ipfs}/bin/ipfs --local config Mounts.IPFS)
  -        mkdir -p $(${ipfs}/bin/ipfs --local config Mounts.IPNS)
  +        ipfs --local config Mounts.FuseAllowOther --json true
  +        mkdir -p $(ipfs --local config Mounts.IPFS)
  +        mkdir -p $(ipfs --local config Mounts.IPNS)
         '' + concatStringsSep "\n" (collect
               isString
               (mapAttrsRecursive
  
positive.code:       --set IPFS_PATH ${cfg.dataDir} \
        --prefix PATH : /run/wrappers/bin
    '';
  in
  
  {
  
    ###### interface
  
  
negative.code: { config, lib, pkgs, ... }:
  with lib;
  let
    inherit (pkgs) ipfs runCommand makeWrapper;
  
    cfg = config.services.ipfs;
  
    ipfsFlags = toString ([
      (optionalString  cfg.autoMount                   "--mount")
      (optionalString  cfg.autoMigrate                 "--migrate")
      (optionalString  cfg.enableGC                    "--enable-gc")
      (optionalString (cfg.serviceFdlimit != null)     "--manage-fdlimit=false")
      (optionalString (cfg.defaultMode == "offline")   "--offline")
      (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";
  