nixos-config/modules/samba.nix

54 lines
1.2 KiB
Nix
Raw Normal View History

2019-09-18 02:23:45 +04:00
{ config, lib, pkgs, ... }:
with rec {
inherit (config) deviceSpecific;
};
with deviceSpecific; {
2019-09-16 15:01:09 +04:00
users.groups.smbgrp.gid = 2001;
# TODO: add nologin shell to this user
users.users.smbuser =
2020-02-05 04:30:49 +04:00
lib.mkIf isHost {
2019-09-16 15:01:09 +04:00
isNormalUser = false;
extraGroups = [
"smbgrp"
];
description = "User for samba sharing";
};
services.samba =
2020-02-05 04:30:49 +04:00
lib.mkIf isHost {
2019-09-16 15:01:09 +04:00
enable = true;
enableNmbd = false;
enableWinbindd = false;
invalidUsers = [ "root" ];
nsswins = false;
securityType = "user";
syncPasswordsByPam = false;
configText = ''
[global]
server string = samba home server
server role = standalone server
disable netbios = yes
smb ports = 445
2019-09-28 02:24:58 +04:00
[data]
2019-09-29 14:59:51 +04:00
path = /media/data
2019-09-16 15:01:09 +04:00
browsable = yes
2019-09-29 14:59:51 +04:00
read only = no
2019-09-16 15:01:09 +04:00
force create mode = 0660
force directory mode = 2770
valid users = @smbgrp
2019-09-28 02:24:58 +04:00
[files]
2019-09-29 14:59:51 +04:00
path = /media/files
2019-09-16 15:01:09 +04:00
browsable = yes
read only = no
force create mode = 0660
force directory mode = 2770
2019-09-28 01:53:49 +04:00
valid users = @smbgrp
2019-09-16 15:01:09 +04:00
'';
};
environment.systemPackages =
2020-02-05 04:30:49 +04:00
if isHost then
2019-09-16 15:01:09 +04:00
[ config.services.samba.package ]
else
[ ];
}