anchor.diff:  
               description = "Kernel NFS server";
   
  -            startOn = "started network-interfaces";
  +            startOn = "started network-interfaces and started portmap";
  +
  +            postStart =
  +              ''
  +                # exports file is ${exports}
  +                # keep this comment so that this job is restarted whenever exports changes!
  +                exportfs -ra
  +              '';
  +          };
  +        }
  +
  +      // optionalAttrs cfg.server.enable
  +        { nfs_kernel_nfsd =
  +          { name = "nfs-kernel-nfsd";
  +
  +            description = "Kernel NFS server";
  +
  +            startOn = "starting nfs-kernel-exports or started portmap";
  +            stopOn = "stopped nfs-kernel-statd or stopping portmap";
   
               preStart =
                 ''
                   export PATH=${pkgs.nfsUtils}/sbin:$PATH
                   mkdir -p /var/lib/nfs
   
  +                # Create a state directory required by NFSv4.
  +                mkdir -p /var/lib/nfs/v4recovery
  +
  +                # rpc.nfsd needs the kernel support
                   ${config.system.sbin.modprobe}/sbin/modprobe nfsd || true
   
                   ${pkgs.sysvtools}/bin/mountpoint -q /proc/fs/nfsd \
  
positive.code:   cfg = config.services.nfsKernel;
  
    exports = pkgs.writeText "exports" cfg.server.exports;
  
  in
  
  
negative.code:                   ''
                  }
  
                  ${pkgs.nfsUtils}/sbin/rpc.nfsd \
                    ${if cfg.server.hostName != null then "-H ${cfg.server.hostName}" else ""} \
                    ${builtins.toString cfg.server.nproc}
  