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:
# 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";

View file

@ -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 ];
}
)
];
}