fiddeling around with the samba share module
This commit is contained in:
parent
d5fe5ba687
commit
e14304fb51
2 changed files with 31 additions and 13 deletions
|
@ -4,6 +4,10 @@
|
|||
# To set password:
|
||||
# nix-shell -p samba --run "smbpasswd -a media"
|
||||
custom.samba-share.enable = true;
|
||||
custom.samba-share.enableWSDD = true;
|
||||
custom.samba-share.folders = {
|
||||
music = "/media/music";
|
||||
};
|
||||
custom.samba-share.private = {
|
||||
media = {
|
||||
folder = "/media";
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
with types;
|
||||
let
|
||||
|
||||
cfg = config.custom.samba-share;
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
options.custom.samba-share = {
|
||||
enable = mkEnableOption "enable custom.samba-share";
|
||||
enableWSDD = mkEnableOption "enable services.samba-wsdd.enable";
|
||||
guestUser = mkOption {
|
||||
default = "media";
|
||||
type = str;
|
||||
description = ''
|
||||
user name a guest users uses.
|
||||
'';
|
||||
};
|
||||
folders = mkOption {
|
||||
default = { };
|
||||
type = with types; attrsOf str;
|
||||
|
@ -52,7 +58,7 @@ in
|
|||
enable = true;
|
||||
# services.samba.securityType = "share";
|
||||
extraConfig = ''
|
||||
guest account = smbguest
|
||||
guest account = ${cfg.guestUser}
|
||||
map to guest = bad user
|
||||
|
||||
# disable printing
|
||||
|
@ -89,20 +95,28 @@ in
|
|||
cfg.private);
|
||||
};
|
||||
|
||||
users.users.smbguest = {
|
||||
name = "smbguest";
|
||||
uid = config.ids.uids.smbguest;
|
||||
description = "smb guest user";
|
||||
home = "/home/smbguest";
|
||||
createHome = true;
|
||||
group = "smbguest";
|
||||
};
|
||||
users.groups.smbguest = { };
|
||||
#users.users.smbguest = {
|
||||
# name = "smbguest";
|
||||
# uid = config.ids.uids.smbguest;
|
||||
# description = "smb guest user";
|
||||
# home = "/home/smbguest";
|
||||
# createHome = true;
|
||||
# group = "smbguest";
|
||||
#};
|
||||
#users.groups.smbguest = { };
|
||||
|
||||
})
|
||||
# todo : maybe better to have a parameter for this
|
||||
(mkIf config.services.syncthing.enable {
|
||||
users.groups."syncthing".members = [ "smbguest" ];
|
||||
})
|
||||
|
||||
(mkIf cfg.enableWSDD {
|
||||
services.samba-wsdd.enable = true;
|
||||
services.samba-wsdd.discovery = true;
|
||||
networking.firewall.allowedTCPPorts = [ 5357 ];
|
||||
networking.firewall.allowedUDPPorts = [ 3702 ];
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue