temp commit
This commit is contained in:
58
modules/nixos/samba/default.nix
Executable file
58
modules/nixos/samba/default.nix
Executable file
@@ -0,0 +1,58 @@
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.nas-samba;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# make shares visible for Windows clients
|
||||
services.samba-wsdd = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
services.netatalk = {
|
||||
enable = cfg.enableTimeMachine;
|
||||
settings = {
|
||||
time-machine = {
|
||||
path = cfg.timeMachinePath;
|
||||
"valid users" = "whoever";
|
||||
"time machine" = cfg.enableTimeMachine;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.enable = true;
|
||||
networking.firewall.allowPing = true;
|
||||
|
||||
services.samba = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
nsswins = true;
|
||||
nmbd.enable = true;
|
||||
settings =
|
||||
let
|
||||
make =
|
||||
name: share:
|
||||
nameValuePair "${name}" {
|
||||
path = share.sharePath;
|
||||
public = if share.enableTimeMachine then "no" else "yes";
|
||||
browseable = if share.browseable then "yes" else "no";
|
||||
writable = "yes";
|
||||
"force group" = "jallen-nas";
|
||||
"read only" = if share.readOnly then "yes" else "no";
|
||||
"guest ok" = if share.guestOk then "yes" else "no";
|
||||
"create mask" = share.createMask;
|
||||
"directory mask" = share.directoryMask;
|
||||
"fruit:aapl" = if share.enableTimeMachine then "yes" else "no";
|
||||
"fruit:time machine" = if share.enableTimeMachine then "yes" else "no";
|
||||
"vfs objects" = "catia fruit streams_xattr";
|
||||
"fruit:time machine max size" = share.timeMachineMaxSize;
|
||||
};
|
||||
in
|
||||
mapAttrs' make cfg.shares;
|
||||
};
|
||||
};
|
||||
}
|
||||
70
modules/nixos/samba/options.nix
Executable file
70
modules/nixos/samba/options.nix
Executable file
@@ -0,0 +1,70 @@
|
||||
{ lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.nas-samba = {
|
||||
enable = mkEnableOption "nas samba service";
|
||||
|
||||
autoStart = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
enableTimeMachine = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
timeMachinePath = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
};
|
||||
hostsAllow = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
};
|
||||
|
||||
shares = mkOption {
|
||||
type = types.attrsOf (
|
||||
types.submodule {
|
||||
options = {
|
||||
public = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
sharePath = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
};
|
||||
readOnly = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
browseable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
guestOk = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
createMask = mkOption {
|
||||
type = types.str;
|
||||
default = "0774";
|
||||
};
|
||||
directoryMask = mkOption {
|
||||
type = types.str;
|
||||
default = "0775";
|
||||
};
|
||||
enableTimeMachine = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
timeMachineMaxSize = mkOption {
|
||||
type = types.str;
|
||||
default = "0K";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user