From e7bcab801cdfe48ba982b0d654cc7230a9de6b13 Mon Sep 17 00:00:00 2001 From: Pascal Bach Date: Wed, 11 Sep 2024 23:27:42 +0200 Subject: [PATCH] nixos/samba: ensure global section is always first The order of the [global] section matters as settings defined there are only applied to shares that are defines after it. --- nixos/modules/services/network-filesystems/samba.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/network-filesystems/samba.nix b/nixos/modules/services/network-filesystems/samba.nix index 2b46a14b672a..f236d44d5d0e 100644 --- a/nixos/modules/services/network-filesystems/samba.nix +++ b/nixos/modules/services/network-filesystems/samba.nix @@ -6,7 +6,11 @@ let cfg = config.services.samba; settingsFormat = pkgs.formats.ini { }; - configFile = settingsFormat.generate "smb.conf" cfg.settings; + # Ensure the global section is always first + globalConfigFile = settingsFormat.generate "smb-global.conf" { global = cfg.settings.global; }; + sharesConfigFile = settingsFormat.generate "smb-shares.conf" (lib.removeAttrs cfg.settings [ "global" ]); + + configFile = pkgs.concatText "smb.conf" [ globalConfigFile sharesConfigFile ]; in