nixos/services.diod: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-30 00:47:08 +02:00
parent a9748cc118
commit 44985668d8

View File

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.diod;
@ -9,9 +8,9 @@ let
allsquash = ${diodBool cfg.allsquash}
auth_required = ${diodBool cfg.authRequired}
exportall = ${diodBool cfg.exportall}
exportopts = "${concatStringsSep "," cfg.exportopts}"
exports = { ${concatStringsSep ", " (map (s: ''"${s}"'' ) cfg.exports)} }
listen = { ${concatStringsSep ", " (map (s: ''"${s}"'' ) cfg.listen)} }
exportopts = "${lib.concatStringsSep "," cfg.exportopts}"
exports = { ${lib.concatStringsSep ", " (map (s: ''"${s}"'' ) cfg.exports)} }
listen = { ${lib.concatStringsSep ", " (map (s: ''"${s}"'' ) cfg.listen)} }
logdest = "${cfg.logdest}"
nwthreads = ${toString cfg.nwthreads}
squashuser = "${cfg.squashuser}"
@ -23,14 +22,14 @@ in
{
options = {
services.diod = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the diod 9P file server.";
};
listen = mkOption {
type = types.listOf types.str;
listen = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "0.0.0.0:564" ];
description = ''
[ "IP:PORT" [,"IP:PORT",...] ]
@ -38,8 +37,8 @@ in
'';
};
exports = mkOption {
type = types.listOf types.str;
exports = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
List the file systems that clients will be allowed to mount. All paths should
@ -54,8 +53,8 @@ in
'';
};
exportall = mkOption {
type = types.bool;
exportall = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Export all file systems listed in /proc/mounts. If new file systems are mounted
@ -65,8 +64,8 @@ in
'';
};
exportopts = mkOption {
type = types.listOf types.str;
exportopts = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
Establish a default set of export options. These are overridden, not appended
@ -74,8 +73,8 @@ in
'';
};
nwthreads = mkOption {
type = types.int;
nwthreads = lib.mkOption {
type = lib.types.int;
default = 16;
description = ''
Sets the (fixed) number of worker threads created to handle 9P
@ -83,16 +82,16 @@ in
'';
};
authRequired = mkOption {
type = types.bool;
authRequired = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Allow clients to connect without authentication, i.e. without a valid MUNGE credential.
'';
};
userdb = mkOption {
type = types.bool;
userdb = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
This option disables password/group lookups. It allows any uid to attach and
@ -100,8 +99,8 @@ in
'';
};
allsquash = mkOption {
type = types.bool;
allsquash = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Remap all users to "nobody". The attaching user need not be present in the
@ -109,16 +108,16 @@ in
'';
};
squashuser = mkOption {
type = types.str;
squashuser = lib.mkOption {
type = lib.types.str;
default = "nobody";
description = ''
Change the squash user. The squash user must be present in the password file.
'';
};
logdest = mkOption {
type = types.str;
logdest = lib.mkOption {
type = lib.types.str;
default = "syslog:daemon:err";
description = ''
Set the destination for logging.
@ -127,8 +126,8 @@ in
};
statfsPassthru = mkOption {
type = types.bool;
statfsPassthru = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
This option configures statfs to return the host file system's type
@ -136,15 +135,15 @@ in
'';
};
extraConfig = mkOption {
type = types.lines;
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Extra configuration options for diod.conf.";
};
};
};
config = mkIf config.services.diod.enable {
config = lib.mkIf config.services.diod.enable {
environment.systemPackages = [ pkgs.diod ];
systemd.services.diod = {