* Don't say `jobs.foo = mkIf condition { ... }' because that will

create an empty job `foo' if the condition is false.  Instead use
  `jobs = optionalAttrs condition { foo = { ... }; }'.
* Enable portmap automatically when using the NFS server or client.

svn path=/nixos/trunk/; revision=20178
This commit is contained in:
Eelco Dolstra 2010-02-22 17:12:26 +00:00
parent 0fb8300bb6
commit cc0a2a6944
1 changed files with 64 additions and 53 deletions

View File

@ -74,8 +74,10 @@ in
config = {
services.portmap.enable = cfg.client.enable || cfg.server.enable;
assertions = mkIf (cfg.client.enable || cfg.server.enable) (singleton
{ assertion = config.services.portmap.enable;
{ assertion = cfg.client.enable || cfg.server.enable;
message = "Please enable portmap (services.portmap.enable) to use nfs-kernel.";
});
@ -84,7 +86,9 @@ in
target = "exports";
});
jobs.nfs_kernel_exports = mkIf cfg.server.enable
jobs =
optionalAttrs cfg.server.enable
{ nfs_kernel_exports =
{ name = "nfs-kernel-exports";
description = "Kernel NFS server";
@ -113,8 +117,10 @@ in
exportfs -ra
'';
};
}
jobs.nfs_kernel_nfsd = mkIf cfg.server.enable
// optionalAttrs cfg.server.enable
{ nfs_kernel_nfsd =
{ name = "nfs-kernel-nfsd";
description = "Kernel NFS server";
@ -124,8 +130,10 @@ in
exec = "${pkgs.nfsUtils}/sbin/rpc.nfsd ${if cfg.server.hostName != null then "-H ${cfg.server.hostName}" else ""} ${builtins.toString cfg.server.nproc}";
};
}
jobs.nfs_kernel_mountd = mkIf cfg.server.enable
// optionalAttrs cfg.server.enable
{ nfs_kernel_mountd =
{ name = "nfs-kernel-mountd";
description = "Kernel NFS server - mount daemon";
@ -135,8 +143,10 @@ in
exec = "${pkgs.nfsUtils}/sbin/rpc.mountd -F -f ${cfg.server.exports}";
};
}
jobs.nfs_kernel_statd = mkIf (cfg.client.enable || cfg.server.enable)
// optionalAttrs (cfg.client.enable || cfg.server.enable)
{ nfs_kernel_statd =
{ name = "nfs-kernel-statd";
description = "Kernel NFS server - Network Status Monitor";
@ -151,6 +161,7 @@ in
exec = "${pkgs.nfsUtils}/sbin/rpc.statd -F";
};
};
};