anchor.diff:    cfg = config.services.nfsKernel;
   
     exports = pkgs.writeText "exports" cfg.server.exports;
  +
  +/*
  +  Description at http://nfs.sourceforge.net/nfs-howto/ar01s03.html :
  +
  +  "If your distribution does not include them in the startup scripts, then then
  +  you should add them, configured to start in the following order:
  +
  +  rpc.portmap
  +  rpc.mountd, rpc.nfsd
  +  rpc.statd, rpc.lockd (if necessary), and
  +  rpc.rquotad"
  +
  +  I tried to mimic that with upstart, playing with stopping/stopped/started/starting
  +  events.
  +
  +  I consider two scenarios:
  +    - Starting at boot. Then, portmap will emit a started event.
  +    - "restart nfs-kernel-exports". Then, portmap will not emit anything. Due
  +      to the comment in postStart, this will happen on nixos-rebuild if
  +      the exportfs file changed.
  +
  +  From these scenarios, I came up with the startOn and stopOn at the time of commiting
  +  this comment.
  +*/
  +
   
   in
   
  
positive.code: 
              description = "Kernel NFS server - mount daemon";
  
              startOn = "started portmap and started nfs-kernel-exports";
              stopOn = "stopped nfs-kernel-nfsd";
  
              daemonType = "fork";
  
  
negative.code:                   ''
                  }
  
                  ${pkgs.nfsUtils}/sbin/rpc.nfsd \
                    ${if cfg.server.hostName != null then "-H ${cfg.server.hostName}" else ""} \
                    ${builtins.toString cfg.server.nproc}
  