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