nixos/services.nfs.server: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:18:59 +02:00 committed by Jörg Thalheim
parent 808c6a991b
commit e14a371aac

View file

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.nfs.server; cfg = config.services.nfs.server;
@ -12,8 +9,8 @@ in
{ {
imports = [ imports = [
(mkRenamedOptionModule [ "services" "nfs" "lockdPort" ] [ "services" "nfs" "server" "lockdPort" ]) (lib.mkRenamedOptionModule [ "services" "nfs" "lockdPort" ] [ "services" "nfs" "server" "lockdPort" ])
(mkRenamedOptionModule [ "services" "nfs" "statdPort" ] [ "services" "nfs" "server" "statdPort" ]) (lib.mkRenamedOptionModule [ "services" "nfs" "statdPort" ] [ "services" "nfs" "server" "statdPort" ])
]; ];
###### interface ###### interface
@ -23,24 +20,24 @@ in
services.nfs = { services.nfs = {
server = { server = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable the kernel's NFS server. Whether to enable the kernel's NFS server.
''; '';
}; };
extraNfsdConfig = mkOption { extraNfsdConfig = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
Extra configuration options for the [nfsd] section of /etc/nfs.conf. Extra configuration options for the [nfsd] section of /etc/nfs.conf.
''; '';
}; };
exports = mkOption { exports = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
Contents of the /etc/exports file. See Contents of the /etc/exports file. See
@ -48,8 +45,8 @@ in
''; '';
}; };
hostName = mkOption { hostName = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = '' description = ''
Hostname or address on which NFS requests will be accepted. Hostname or address on which NFS requests will be accepted.
@ -58,22 +55,22 @@ in
''; '';
}; };
nproc = mkOption { nproc = lib.mkOption {
type = types.int; type = lib.types.int;
default = 8; default = 8;
description = '' description = ''
Number of NFS server threads. Defaults to the recommended value of 8. Number of NFS server threads. Defaults to the recommended value of 8.
''; '';
}; };
createMountPoints = mkOption { createMountPoints = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Whether to create the mount points in the exports file at startup time."; description = "Whether to create the mount points in the exports file at startup time.";
}; };
mountdPort = mkOption { mountdPort = lib.mkOption {
type = types.nullOr types.int; type = lib.types.nullOr lib.types.int;
default = null; default = null;
example = 4002; example = 4002;
description = '' description = ''
@ -81,8 +78,8 @@ in
''; '';
}; };
lockdPort = mkOption { lockdPort = lib.mkOption {
type = types.nullOr types.int; type = lib.types.nullOr lib.types.int;
default = null; default = null;
example = 4001; example = 4001;
description = '' description = ''
@ -92,8 +89,8 @@ in
''; '';
}; };
statdPort = mkOption { statdPort = lib.mkOption {
type = types.nullOr types.int; type = lib.types.nullOr lib.types.int;
default = null; default = null;
example = 4000; example = 4000;
description = '' description = ''
@ -111,7 +108,7 @@ in
###### implementation ###### implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.rpcbind.enable = true; services.rpcbind.enable = true;
@ -137,7 +134,7 @@ in
'' ''
mkdir -p /var/lib/nfs mkdir -p /var/lib/nfs
${optionalString cfg.createMountPoints ${lib.optionalString cfg.createMountPoints
'' ''
# create export directories: # create export directories:
# skip comments, take first col which may either be a quoted # skip comments, take first col which may either be a quoted