fiddeling around with the samba share module

This commit is contained in:
Ingolf Wagner 2023-07-03 09:39:14 +02:00
parent d5fe5ba687
commit e14304fb51
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 31 additions and 13 deletions

View file

@ -4,6 +4,10 @@
# To set password: # To set password:
# nix-shell -p samba --run "smbpasswd -a media" # nix-shell -p samba --run "smbpasswd -a media"
custom.samba-share.enable = true; custom.samba-share.enable = true;
custom.samba-share.enableWSDD = true;
custom.samba-share.folders = {
music = "/media/music";
};
custom.samba-share.private = { custom.samba-share.private = {
media = { media = {
folder = "/media"; folder = "/media";

View file

@ -1,16 +1,22 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
with types;
let let
cfg = config.custom.samba-share; cfg = config.custom.samba-share;
in in
{ {
options.custom.samba-share = { options.custom.samba-share = {
enable = mkEnableOption "enable 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 { folders = mkOption {
default = { }; default = { };
type = with types; attrsOf str; type = with types; attrsOf str;
@ -52,7 +58,7 @@ in
enable = true; enable = true;
# services.samba.securityType = "share"; # services.samba.securityType = "share";
extraConfig = '' extraConfig = ''
guest account = smbguest guest account = ${cfg.guestUser}
map to guest = bad user map to guest = bad user
# disable printing # disable printing
@ -89,20 +95,28 @@ in
cfg.private); cfg.private);
}; };
users.users.smbguest = { #users.users.smbguest = {
name = "smbguest"; # name = "smbguest";
uid = config.ids.uids.smbguest; # uid = config.ids.uids.smbguest;
description = "smb guest user"; # description = "smb guest user";
home = "/home/smbguest"; # home = "/home/smbguest";
createHome = true; # createHome = true;
group = "smbguest"; # group = "smbguest";
}; #};
users.groups.smbguest = { }; #users.groups.smbguest = { };
}) })
# todo : maybe better to have a parameter for this # todo : maybe better to have a parameter for this
(mkIf config.services.syncthing.enable { (mkIf config.services.syncthing.enable {
users.groups."syncthing".members = [ "smbguest" ]; 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 ];
}
)
]; ];
} }