From 8616aca59a9c283b19d7c611461b7377412398b8 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Mon, 18 Mar 2024 22:01:29 +0100 Subject: [PATCH] nixos/davfs2: Convert extraConfig to freeform type --- .../manual/release-notes/rl-2405.section.md | 2 + .../services/network-filesystems/davfs2.nix | 49 +++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index 1a86beaba73f..59159c2d8a5c 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -175,6 +175,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m - `paperless`' `services.paperless.extraConfig` setting has been removed and converted to the freeform type and option named `services.paperless.settings`. +- `davfs2`' `services.davfs2.extraConfig` setting has been deprecated and converted to the freeform type option named `services.davfs2.settings` according to RFC42. + - `services.homepage-dashboard` now takes it's configuration using native Nix expressions, rather than dumping templated configurations into `/var/lib/homepage-dashboard` where they were previously managed manually. There are now new options which allow the configuration of bookmarks, services, widgets and custom CSS/JS natively in Nix. - `hare` may now be cross-compiled. For that to work, however, `haredoc` needed to stop being built together with it. Thus, the latter is now its own package with the name of `haredoc`. diff --git a/nixos/modules/services/network-filesystems/davfs2.nix b/nixos/modules/services/network-filesystems/davfs2.nix index 8024cfba08be..90bb5ee5e66c 100644 --- a/nixos/modules/services/network-filesystems/davfs2.nix +++ b/nixos/modules/services/network-filesystems/davfs2.nix @@ -3,14 +3,22 @@ with lib; let + toStr = value: + if true == value then "yes" + else if false == value then "no" + else toString value; + cfg = config.services.davfs2; - cfgFile = pkgs.writeText "davfs2.conf" '' - dav_user ${cfg.davUser} - dav_group ${cfg.davGroup} + format = pkgs.formats.toml { }; + configFile = let + settings = mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings; + in pkgs.writeText "davfs2.conf" '' + ${concatStringsSep "\n" settings} ${cfg.extraConfig} ''; in { + options.services.davfs2 = { enable = mkOption { type = types.bool; @@ -49,13 +57,46 @@ in ''; description = lib.mdDoc '' Extra lines appended to the configuration of davfs2. + See {manpage}`davfs2.conf(5)` for available settings. + + **Note**: Please pass structured settings via + {option}`settings` instead, this option + will get deprecated in the future. + '' ; + }; + + settings = mkOption { + type = types.submodule { + freeformType = format.type; + }; + default = {}; + example = literalExpression '' + { + kernel_fs = "coda"; + proxy = "foo.bar:8080"; + use_locks = 0; + } + ''; + description = lib.mdDoc '' + Extra settings appended to the configuration of davfs2. + See {manpage}`davfs2.conf(5)` for available settings. '' ; }; }; config = mkIf cfg.enable { + + warnings = lib.optional (cfg.extraConfig != null) '' + services.davfs2.extraConfig will be deprecated in future releases, please use the settings option now. + ''; + environment.systemPackages = [ pkgs.davfs2 ]; - environment.etc."davfs2/davfs2.conf".source = cfgFile; + environment.etc."davfs2/davfs2.conf".source = configFile; + + services.davfs2.settings = { + dav_user = cfg.davUser; + dav_group = cfg.davGroup; + }; users.groups = optionalAttrs (cfg.davGroup == "davfs2") { davfs2.gid = config.ids.gids.davfs2;