alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
yellow: add ksmbd
author
Jörg Thalheim
committer
lassulus
date
2 years ago
(Nov 8, 2023, 8:01 PM CET)
commit
32455e5a
32455e5ade5ea75579cd626b9720152add856962
parent
248adbef
248adbef20bc67e6632c7a878ccced41d6cccd69
+122
-59
3 changed files
Expand all
Collapse all
Unified
Split
2configs
services
flix
default.nix
3modules
default.nix
ksmbd.nix
+1
3modules/default.nix
View file
Reviewed
···
5
5
./drbd.nix
6
6
./folderPerms.nix
7
7
./klem.nix
8
8
+
./ksmbd.nix
8
9
./mysql-backup.nix
9
10
./nichtparasoup.nix
10
11
./screenlock.nix
+113
3modules/ksmbd.nix
View file
Reviewed
···
1
1
+
{ config, pkgs, lib, ... }:
2
2
+
3
3
+
let
4
4
+
cfg = config.services.ksmbd;
5
5
+
6
6
+
smbToString = x:
7
7
+
if builtins.typeOf x == "bool"
8
8
+
then lib.boolToString x
9
9
+
else toString x;
10
10
+
11
11
+
shareConfig = name:
12
12
+
let share = lib.getAttr name cfg.shares; in
13
13
+
"[${name}]\n " + (smbToString (
14
14
+
map
15
15
+
(key: "${key} = ${smbToString (lib.getAttr key share)}\n")
16
16
+
(lib.attrNames share)
17
17
+
));
18
18
+
in
19
19
+
{
20
20
+
options = {
21
21
+
services.ksmbd = {
22
22
+
enable = lib.mkEnableOption "Enable cifsd kernel server";
23
23
+
24
24
+
openFirewall = lib.mkOption {
25
25
+
type = lib.types.bool;
26
26
+
default = false;
27
27
+
description = lib.mdDoc ''
28
28
+
Whether to automatically open the necessary ports in the firewall.
29
29
+
'';
30
30
+
};
31
31
+
32
32
+
securityType = lib.mkOption {
33
33
+
type = lib.types.str;
34
34
+
default = "user";
35
35
+
description = "Samba security type";
36
36
+
};
37
37
+
38
38
+
extraConfig = lib.mkOption {
39
39
+
type = lib.types.lines;
40
40
+
default = "";
41
41
+
description = ''
42
42
+
Additional global section and extra section lines go in here.
43
43
+
'';
44
44
+
example = ''
45
45
+
guest account = nobody
46
46
+
map to guest = bad user
47
47
+
'';
48
48
+
};
49
49
+
50
50
+
shares = lib.mkOption {
51
51
+
default = { };
52
52
+
description = ''
53
53
+
A set describing shared resources.
54
54
+
See <command>man smb.conf</command> for options.
55
55
+
'';
56
56
+
type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified);
57
57
+
example = lib.literalExample ''
58
58
+
{ public =
59
59
+
{ path = "/srv/public";
60
60
+
"read only" = true;
61
61
+
browseable = "yes";
62
62
+
"guest ok" = "yes";
63
63
+
comment = "Public samba share.";
64
64
+
};
65
65
+
}
66
66
+
'';
67
67
+
};
68
68
+
69
69
+
users = lib.mkOption {
70
70
+
default = [ ];
71
71
+
type = lib.types.listOf (lib.types.submodule {
72
72
+
options = {
73
73
+
user = lib.mkOption {
74
74
+
type = lib.types.str;
75
75
+
};
76
76
+
passwordFile = lib.mkOption {
77
77
+
type = lib.types.path;
78
78
+
};
79
79
+
};
80
80
+
});
81
81
+
};
82
82
+
};
83
83
+
};
84
84
+
config = lib.mkIf cfg.enable {
85
85
+
boot.kernelModules = [ "ksmbd" ];
86
86
+
environment.systemPackages = [ pkgs.ksmbd-tools ];
87
87
+
88
88
+
environment.etc."ksmbd/ksmbd.conf".text = ''
89
89
+
[global]
90
90
+
security = ${cfg.securityType}
91
91
+
${cfg.extraConfig}
92
92
+
93
93
+
${smbToString (map shareConfig (lib.attrNames cfg.shares))}
94
94
+
'';
95
95
+
96
96
+
systemd.services.ksmbd = {
97
97
+
wantedBy = [ "multi-user.target" ];
98
98
+
after = [ "network.target" ];
99
99
+
path = [ pkgs.ksmbd-tools ];
100
100
+
preStart = builtins.concatStringsSep "\n"
101
101
+
(map (it: "ksmbd.adduser -i /run/ksmbd/passwd -a ${it.user} < ${it.passwordFile}") cfg.users);
102
102
+
serviceConfig = {
103
103
+
Type = "forking";
104
104
+
ExecStart = "${pkgs.ksmbd-tools}/bin/ksmbd.mountd -C /etc/ksmbd/ksmbd.conf -P /run/ksmbd/passwd";
105
105
+
Restart = "always";
106
106
+
PrivateTmp = true;
107
107
+
RuntimeDirectory = "ksmbd";
108
108
+
};
109
109
+
};
110
110
+
111
111
+
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ 445 ];
112
112
+
};
113
113
+
}
+8
-59
2configs/services/flix/default.nix
View file
Reviewed
···
163
163
};
164
164
};
165
165
166
166
-
services.samba = {
167
167
-
enable = true;
168
168
-
enableNmbd = false;
169
169
-
extraConfig = ''
170
170
-
workgroup = WORKGROUP
171
171
-
server string = ${config.networking.hostName}
172
172
-
# only allow retiolum addresses
173
173
-
hosts allow = 42::/16 10.243.0.0/16 10.244.0.0/16
174
174
-
175
175
-
# Use sendfile() for performance gain
176
176
-
use sendfile = true
177
177
-
178
178
-
# No NetBIOS is needed
179
179
-
disable netbios = true
180
180
-
181
181
-
# Only mangle non-valid NTFS names, don't care about DOS support
182
182
-
mangled names = illegal
183
183
-
184
184
-
# Performance optimizations
185
185
-
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
186
186
-
187
187
-
# Disable all printing
188
188
-
load printers = false
189
189
-
disable spoolss = true
190
190
-
printcap name = /dev/null
191
191
-
192
192
-
map to guest = Bad User
193
193
-
max log size = 50
194
194
-
dns proxy = no
195
195
-
security = user
196
196
-
197
197
-
[global]
198
198
-
syslog only = yes
199
199
-
'';
200
200
-
shares.public = {
201
201
-
comment = "Warez";
202
202
-
path = "/var/download";
203
203
-
public = "yes";
204
204
-
"only guest" = "yes";
205
205
-
"create mask" = "0644";
206
206
-
"directory mask" = "2777";
207
207
-
writable = "no";
208
208
-
printable = "no";
209
209
-
};
166
166
+
services.ksmbd.enable = true;
167
167
+
services.ksmbd.shares.public = {
168
168
+
path = "/var/download";
169
169
+
"read only" = true;
170
170
+
browseable = "yes";
171
171
+
"guest ok" = "yes";
172
172
+
comment = "Warez.";
210
173
};
211
174
212
175
systemd.services.bruellwuerfel =
···
248
211
{ predicate = "-p tcp --dport 7878"; target = "ACCEPT"; } # radarr
249
212
{ predicate = "-p tcp --dport 6767"; target = "ACCEPT"; } # bazarr
250
213
251
251
-
# smbd
252
252
-
{ predicate = "-i retiolum -p tcp --dport 445"; target = "ACCEPT"; }
253
253
-
{ predicate = "-i retiolum -p tcp --dport 111"; target = "ACCEPT"; }
254
254
-
{ predicate = "-i retiolum -p udp --dport 111"; target = "ACCEPT"; }
255
255
-
{ predicate = "-i retiolum -p tcp --dport 2049"; target = "ACCEPT"; }
256
256
-
{ predicate = "-i retiolum -p udp --dport 2049"; target = "ACCEPT"; }
257
257
-
{ predicate = "-i retiolum -p tcp --dport 4000:4002"; target = "ACCEPT"; }
258
258
-
{ predicate = "-i retiolum -p udp --dport 4000:4002"; target = "ACCEPT"; }
259
259
-
{ predicate = "-i wiregrill -p tcp --dport 445"; target = "ACCEPT"; }
260
260
-
{ predicate = "-i wiregrill -p tcp --dport 111"; target = "ACCEPT"; }
261
261
-
{ predicate = "-i wiregrill -p udp --dport 111"; target = "ACCEPT"; }
262
262
-
{ predicate = "-i wiregrill -p tcp --dport 2049"; target = "ACCEPT"; }
263
263
-
{ predicate = "-i wiregrill -p udp --dport 2049"; target = "ACCEPT"; }
264
264
-
{ predicate = "-i wiregrill -p tcp --dport 4000:4002"; target = "ACCEPT"; }
265
265
-
{ predicate = "-i wiregrill -p udp --dport 4000:4002"; target = "ACCEPT"; }
214
214
+
{ predicate = "-i retiolum -p tcp --dport 445"; target = "ACCEPT"; } # ksmb
266
215
];
267
216
};
268
217