summaryrefslogtreecommitdiff
path: root/hosts/vidhar/samba.nix
blob: b37226176bb94ad5c034445a4a2d9ec4498f96cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ config, lib, pkgs, ... }:
{
  config = {
    services.samba = {
      enable = true;
      securityType = "user";
      extraConfig = ''
        domain master = yes
        workgroup = WORKGROUP
        load printers = no
        printing = bsd
        printcap name = /dev/null
        disable spoolss = yes
        guest account = nobody
        bind interfaces only = yes
        interfaces = lo lan
      '';
      shares = {
        homes = {
          comment = "Home Directories";
          path = "/home/%S";
          browseable = "no";
          "valid users" = "%S";
          "read only" = "no";
          "create mask" = "0700";
          "directory mask" = "0700";
          "vfs objects" = "shadow_copy2";
          "shadow:snapdir" = ".zfs/snapshot";
          "shadow:sort" = "desc";
          "shadow:format" = "%Y-%m-%d-%Hh%MU";
          "shadow:snapprefix" = "^zfs-auto-snap_\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}";
          "shadow:delimiter" = "-";
        };
        eos = {
          comment = "Disk image of eos";
          browseable = true;
          "valid users" = "mherold";
          writeable = "true";
          path = "/srv/eos";
        };
      };
    };
    services.samba-wsdd = {
      enable = true;
      workgroup = "WORKGROUP";
      interface = [ "lo" "lan" ];
    };

    fileSystems."/srv/eos.lower" = {
      device = "/dev/zvol/hdd-raid6/safe/home/mherold/eos/base";
      fsType = "ntfs3";
      options = [ "ro" "uid=mherold" "gid=users" "fmask=0177" "dmask=0077" "nofail" "noauto" ];
    };

    fileSystems."/srv/eos.upper" = {
      device = "/dev/zvol/hdd-raid6/safe/home/mherold/eos/upper";
      fsType = "ext4";
      options = [ "nofail" "noauto" ];
    };

    systemd.mounts = [
      {
        wantedBy = [ "samba-smbd.service" ];
        before = [ "samba-smbd.service" ];

        where = "/srv/eos";
        what = "overlay";
        type = "overlay";
        options = lib.concatStringsSep ","
          [ "lowerdir=/srv/eos.lower"
            "upperdir=/srv/eos.upper/upper"
            "workdir=/srv/eos.upper/work"
          ];

        unitConfig = {
          RequiresMountsFor = [ "/srv/eos.lower" "/srv/eos.upper" ];
        };
      }
    ];
  };
}