2d57847f16
Turns out that remote-fs-pre.target is not actually "wanted" anywhere, so statd is not started before remote filesystems are mounted. But remote filesystems do "want" network-online.target, so we can use that to pull in statd and idmapd. Not sure if this is really the right thing to do, but it works for now. Background: https://bugzilla.redhat.com/show_bug.cgi?id=787314 http://hydra.nixos.org/build/5542230
95 lines
2.3 KiB
Nix
95 lines
2.3 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
|
|
|
inInitrd = any (fs: fs == "nfs") config.boot.initrd.supportedFilesystems;
|
|
|
|
nfsStateDir = "/var/lib/nfs";
|
|
|
|
rpcMountpoint = "${nfsStateDir}/rpc_pipefs";
|
|
|
|
idmapdConfFile = pkgs.writeText "idmapd.conf" ''
|
|
[General]
|
|
Pipefs-Directory = ${rpcMountpoint}
|
|
${optionalString (config.networking.domain != "")
|
|
"Domain = ${config.networking.domain}"}
|
|
|
|
[Mapping]
|
|
Nobody-User = nobody
|
|
Nobody-Group = nogroup
|
|
|
|
[Translation]
|
|
Method = nsswitch
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### implementation
|
|
|
|
config = mkIf (any (fs: fs == "nfs" || fs == "nfs4") config.boot.supportedFilesystems) {
|
|
|
|
services.rpcbind.enable = true;
|
|
|
|
system.fsPackages = [ pkgs.nfsUtils ];
|
|
|
|
boot.kernelModules = [ "sunrpc" ];
|
|
|
|
boot.initrd.kernelModules = mkIf inInitrd [ "nfs" ];
|
|
|
|
systemd.services.statd =
|
|
{ description = "NFSv3 Network Status Monitor";
|
|
|
|
path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
|
|
|
|
wantedBy = [ "network-online.target" "multi-user.target" ];
|
|
before = [ "network-online.target" ];
|
|
requires = [ "basic.target" "rpcbind.service" ];
|
|
after = [ "basic.target" "rpcbind.service" "network.target" ];
|
|
|
|
unitConfig.DefaultDependencies = false; # don't stop during shutdown
|
|
|
|
preStart =
|
|
''
|
|
mkdir -p ${nfsStateDir}/sm
|
|
mkdir -p ${nfsStateDir}/sm.bak
|
|
sm-notify -d
|
|
'';
|
|
|
|
serviceConfig.Type = "forking";
|
|
serviceConfig.ExecStart = "@${pkgs.nfsUtils}/sbin/rpc.statd rpc.statd --no-notify";
|
|
serviceConfig.Restart = "always";
|
|
};
|
|
|
|
systemd.services.idmapd =
|
|
{ description = "NFSv4 ID Mapping Daemon";
|
|
|
|
path = [ pkgs.sysvtools pkgs.utillinux ];
|
|
|
|
wantedBy = [ "network-online.target" "multi-user.target" ];
|
|
before = [ "network-online.target" ];
|
|
requires = [ "rpcbind.service" ];
|
|
after = [ "rpcbind.service" ];
|
|
|
|
preStart =
|
|
''
|
|
mkdir -p ${rpcMountpoint}
|
|
mount -t rpc_pipefs rpc_pipefs ${rpcMountpoint}
|
|
'';
|
|
|
|
postStop =
|
|
''
|
|
umount ${rpcMountpoint}
|
|
'';
|
|
|
|
serviceConfig.Type = "forking";
|
|
serviceConfig.ExecStart = "@${pkgs.nfsUtils}/sbin/rpc.idmapd rpc.idmapd -c ${idmapdConfFile}";
|
|
serviceConfig.Restart = "always";
|
|
};
|
|
|
|
};
|
|
}
|