From a60e4033cad693ccab024aa88f095b056594cc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9clairevoyant?= <848000+eclairevoyant@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:08:08 -0400 Subject: [PATCH] nixos/davfs2: ensure extraConfig and settings are mutually exclusive --- .../services/network-filesystems/davfs2.nix | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/network-filesystems/davfs2.nix b/nixos/modules/services/network-filesystems/davfs2.nix index 2f616b076dff..23c04658031f 100644 --- a/nixos/modules/services/network-filesystems/davfs2.nix +++ b/nixos/modules/services/network-filesystems/davfs2.nix @@ -19,13 +19,15 @@ let else if builtins.isString value then "\"${escapeString value}\"" else toString value; - configFile = pkgs.writeText "davfs2.conf" '' - ${toINIWithGlobalSection { - mkSectionName = escapeString; - mkKeyValue = k: v: "${k} ${formatValue v}"; - } cfg.settings} - ${cfg.extraConfig} - ''; + configFile = pkgs.writeText "davfs2.conf" ( + if (cfg.settings != { }) then + (toINIWithGlobalSection { + mkSectionName = escapeString; + mkKeyValue = k: v: "${k} ${formatValue v}"; + } cfg.settings) + else + cfg.extraConfig + ); in { @@ -107,6 +109,16 @@ in config = mkIf cfg.enable { + assertions = [ + { + assertion = cfg.extraConfig != "" -> cfg.settings == { }; + message = '' + services.davfs2.extraConfig and services.davfs2.settings cannot be used together. + Please prefer using services.davfs2.settings. + ''; + } + ]; + warnings = optional (cfg.extraConfig != "") '' services.davfs2.extraConfig will be deprecated in future releases; please use services.davfs2.settings instead.