mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-01 01:33:20 +00:00
nixos/services.nfs: remove with lib;
This commit is contained in:
parent
a83ffb43de
commit
dd7ab59690
@ -1,7 +1,4 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
inInitrd = config.boot.initrd.supportedFilesystems.nfs or false;
|
||||
@ -16,15 +13,15 @@ let
|
||||
|
||||
# merge parameters from services.nfs.server
|
||||
nfsConfSettings =
|
||||
optionalAttrs (cfg.server.nproc != null) {
|
||||
lib.optionalAttrs (cfg.server.nproc != null) {
|
||||
nfsd.threads = cfg.server.nproc;
|
||||
} // optionalAttrs (cfg.server.hostName != null) {
|
||||
} // lib.optionalAttrs (cfg.server.hostName != null) {
|
||||
nfsd.host= cfg.hostName;
|
||||
} // optionalAttrs (cfg.server.mountdPort != null) {
|
||||
} // lib.optionalAttrs (cfg.server.mountdPort != null) {
|
||||
mountd.port = cfg.server.mountdPort;
|
||||
} // optionalAttrs (cfg.server.statdPort != null) {
|
||||
} // lib.optionalAttrs (cfg.server.statdPort != null) {
|
||||
statd.port = cfg.server.statdPort;
|
||||
} // optionalAttrs (cfg.server.lockdPort != null) {
|
||||
} // lib.optionalAttrs (cfg.server.lockdPort != null) {
|
||||
lockd.port = cfg.server.lockdPort;
|
||||
lockd.udp-port = cfg.server.lockdPort;
|
||||
};
|
||||
@ -32,17 +29,17 @@ let
|
||||
nfsConfDeprecated = cfg.extraConfig + ''
|
||||
[nfsd]
|
||||
threads=${toString cfg.server.nproc}
|
||||
${optionalString (cfg.server.hostName != null) "host=${cfg.server.hostName}"}
|
||||
${lib.optionalString (cfg.server.hostName != null) "host=${cfg.server.hostName}"}
|
||||
${cfg.server.extraNfsdConfig}
|
||||
|
||||
[mountd]
|
||||
${optionalString (cfg.server.mountdPort != null) "port=${toString cfg.server.mountdPort}"}
|
||||
${lib.optionalString (cfg.server.mountdPort != null) "port=${toString cfg.server.mountdPort}"}
|
||||
|
||||
[statd]
|
||||
${optionalString (cfg.server.statdPort != null) "port=${toString cfg.server.statdPort}"}
|
||||
${lib.optionalString (cfg.server.statdPort != null) "port=${toString cfg.server.statdPort}"}
|
||||
|
||||
[lockd]
|
||||
${optionalString (cfg.server.lockdPort != null) ''
|
||||
${lib.optionalString (cfg.server.lockdPort != null) ''
|
||||
port=${toString cfg.server.lockdPort}
|
||||
udp-port=${toString cfg.server.lockdPort}
|
||||
''}
|
||||
@ -50,7 +47,7 @@ let
|
||||
|
||||
nfsConfFile =
|
||||
if cfg.settings != {}
|
||||
then format.generate "nfs.conf" (recursiveUpdate nfsConfSettings cfg.settings)
|
||||
then format.generate "nfs.conf" (lib.recursiveUpdate nfsConfSettings cfg.settings)
|
||||
else pkgs.writeText "nfs.conf" nfsConfDeprecated;
|
||||
|
||||
requestKeyConfFile = pkgs.writeText "request-key.conf" ''
|
||||
@ -66,7 +63,7 @@ in
|
||||
|
||||
options = {
|
||||
services.nfs = {
|
||||
idmapd.settings = mkOption {
|
||||
idmapd.settings = lib.mkOption {
|
||||
type = format.type;
|
||||
default = {};
|
||||
description = ''
|
||||
@ -74,7 +71,7 @@ in
|
||||
<https://linux.die.net/man/5/idmapd.conf>
|
||||
for details.
|
||||
'';
|
||||
example = literalExpression ''
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
Translation = {
|
||||
GSS-Methods = "static,nsswitch";
|
||||
@ -85,21 +82,21 @@ in
|
||||
}
|
||||
'';
|
||||
};
|
||||
settings = mkOption {
|
||||
settings = lib.mkOption {
|
||||
type = format.type;
|
||||
default = {};
|
||||
description = ''
|
||||
General configuration for NFS daemons and tools.
|
||||
See nfs.conf(5) and related man pages for details.
|
||||
'';
|
||||
example = literalExpression ''
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
mountd.manage-gids = true;
|
||||
}
|
||||
'';
|
||||
};
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
extraConfig = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra nfs-utils configuration.
|
||||
@ -110,12 +107,12 @@ in
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf (config.boot.supportedFilesystems.nfs or config.boot.supportedFilesystems.nfs4 or false) {
|
||||
config = lib.mkIf (config.boot.supportedFilesystems.nfs or config.boot.supportedFilesystems.nfs4 or false) {
|
||||
|
||||
warnings =
|
||||
(optional (cfg.extraConfig != "") ''
|
||||
(lib.optional (cfg.extraConfig != "") ''
|
||||
`services.nfs.extraConfig` is deprecated. Use `services.nfs.settings` instead.
|
||||
'') ++ (optional (cfg.server.extraNfsdConfig != "") ''
|
||||
'') ++ (lib.optional (cfg.server.extraNfsdConfig != "") ''
|
||||
`services.nfs.server.extraNfsdConfig` is deprecated. Use `services.nfs.settings` instead.
|
||||
'');
|
||||
assertions = [{
|
||||
@ -126,9 +123,9 @@ in
|
||||
services.rpcbind.enable = true;
|
||||
|
||||
services.nfs.idmapd.settings = {
|
||||
General = mkMerge [
|
||||
General = lib.mkMerge [
|
||||
{ Pipefs-Directory = rpcMountpoint; }
|
||||
(mkIf (config.networking.domain != null) { Domain = config.networking.domain; })
|
||||
(lib.mkIf (config.networking.domain != null) { Domain = config.networking.domain; })
|
||||
];
|
||||
Mapping = {
|
||||
Nobody-User = "nobody";
|
||||
@ -141,7 +138,7 @@ in
|
||||
|
||||
system.fsPackages = [ pkgs.nfs-utils ];
|
||||
|
||||
boot.initrd.kernelModules = mkIf inInitrd [ "nfs" ];
|
||||
boot.initrd.kernelModules = lib.mkIf inInitrd [ "nfs" ];
|
||||
|
||||
systemd.packages = [ pkgs.nfs-utils ];
|
||||
|
||||
@ -167,12 +164,12 @@ in
|
||||
|
||||
systemd.services.nfs-mountd =
|
||||
{ restartTriggers = [ nfsConfFile ];
|
||||
enable = mkDefault false;
|
||||
enable = lib.mkDefault false;
|
||||
};
|
||||
|
||||
systemd.services.nfs-server =
|
||||
{ restartTriggers = [ nfsConfFile ];
|
||||
enable = mkDefault false;
|
||||
enable = lib.mkDefault false;
|
||||
};
|
||||
|
||||
systemd.services.auth-rpcgss-module =
|
||||
|
Loading…
Reference in New Issue
Block a user