nixos: configure samba and rsync shares with sets

This commit is contained in:
Emery Hemingway
2014-12-07 15:42:22 -05:00
parent e5d92d45b7
commit f30748a7cd
2 changed files with 75 additions and 81 deletions
@@ -27,6 +27,14 @@ let
mkdir -p ${privateDir}
'';
shareConfig = name:
let share = getAttr name cfg.shares; in
"[${name}]\n " + (toString (
map
(key: "${key} = ${toString (getAttr key share)}\n")
(attrNames share)
));
configFile = pkgs.writeText "smb.conf"
(if cfg.configText != null then cfg.configText else
''
@@ -36,6 +44,8 @@ let
${optionalString cfg.syncPasswordsByPam "pam password change = true"}
${cfg.extraConfig}
${toString (map shareConfig (attrNames cfg.shares))}
'');
# This may include nss_ldap, needed for samba if it has to use ldap.
@@ -159,6 +169,23 @@ in
'';
};
shares = mkOption {
default = {};
description =
''
A set describing shared resources.
See <command>man smb.conf</command> for options.
'';
type = types.attrsOf (types.attrsOf types.str);
example =
{ srv =
{ path = "/srv";
"read only" = "yes";
comment = "Public samba share.";
};
};
};
};
};