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