nixos/davfs2: remove top-level with lib;

This commit is contained in:
éclairevoyant 2024-04-08 18:45:48 -04:00
parent 6cbffaae4c
commit 0ac090f91a
No known key found for this signature in database
GPG Key ID: E3813AEAA02DB54B

View File

@ -1,35 +1,34 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
toStr = value: toStr = value:
if true == value then "yes" if true == value then "yes"
else if false == value then "no" else if false == value then "no"
else toString value; else toString value;
inherit (lib.attrsets) mapAttrsToList optionalAttrs;
inherit (lib.lists) optional;
inherit (lib.modules) mkIf;
inherit (lib.options) literalExpression mkEnableOption mkOption;
inherit (lib.strings) concatLines;
inherit (lib.types) lines str submodule;
cfg = config.services.davfs2; cfg = config.services.davfs2;
format = pkgs.formats.toml { }; format = pkgs.formats.toml { };
configFile = let configFile = let
settings = mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings; settings = mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings;
in pkgs.writeText "davfs2.conf" '' in pkgs.writeText "davfs2.conf" ''
${concatStringsSep "\n" settings} ${concatLines settings}
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
in in
{ {
options.services.davfs2 = { options.services.davfs2 = {
enable = mkOption { enable = mkEnableOption "davfs2";
type = types.bool;
default = false;
description = ''
Whether to enable davfs2.
'';
};
davUser = mkOption { davUser = mkOption {
type = types.str; type = str;
default = "davfs2"; default = "davfs2";
description = '' description = ''
When invoked by root the mount.davfs daemon will run as this user. When invoked by root the mount.davfs daemon will run as this user.
@ -38,7 +37,7 @@ in
}; };
davGroup = mkOption { davGroup = mkOption {
type = types.str; type = str;
default = "davfs2"; default = "davfs2";
description = '' description = ''
The group of the running mount.davfs daemon. Ordinary users must be The group of the running mount.davfs daemon. Ordinary users must be
@ -48,7 +47,7 @@ in
}; };
extraConfig = mkOption { extraConfig = mkOption {
type = types.lines; type = lines;
default = ""; default = "";
example = '' example = ''
kernel_fs coda kernel_fs coda
@ -66,7 +65,7 @@ in
}; };
settings = mkOption { settings = mkOption {
type = types.submodule { type = submodule {
freeformType = format.type; freeformType = format.type;
}; };
default = {}; default = {};
@ -86,7 +85,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
warnings = lib.optional (cfg.extraConfig != "") '' warnings = optional (cfg.extraConfig != "") ''
services.davfs2.extraConfig will be deprecated in future releases; services.davfs2.extraConfig will be deprecated in future releases;
please use services.davfs2.settings instead. please use services.davfs2.settings instead.
''; '';