{ lib, namespace, ... }:
with lib;
{
  options.${namespace}.samba = {
    enable = mkEnableOption "nas samba service";

    autoStart = mkOption {
      type = types.bool;
      default = true;
    };
    enableTimeMachine = mkOption {
      type = types.bool;
      default = false;
    };
    timeMachinePath = mkOption {
      type = types.str;
      default = "";
    };
    hostsAllow = mkOption {
      type = types.str;
      default = "";
    };

    shares = mkOption {
      type = types.attrsOf (
        types.submodule {
          options = {
            public = mkOption {
              type = types.bool;
              default = false;
            };
            sharePath = mkOption {
              type = types.str;
              default = "";
            };
            readOnly = mkOption {
              type = types.bool;
              default = false;
            };
            browseable = mkOption {
              type = types.bool;
              default = true;
            };
            guestOk = mkOption {
              type = types.bool;
              default = true;
            };
            createMask = mkOption {
              type = types.str;
              default = "0774";
            };
            directoryMask = mkOption {
              type = types.str;
              default = "0775";
            };
            enableTimeMachine = mkOption {
              type = types.bool;
              default = false;
            };
            timeMachineMaxSize = mkOption {
              type = types.str;
              default = "0K";
            };
          };
        }
      );
      default = { };
    };
  };
}
