summaryrefslogtreecommitdiff
path: root/hosts/shared/hardware-configuration.nix
blob: d7499683a9e99cd7017b2de3d4e1ed01700652b9 (plain) (blame)
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
{ config, ... }:
let
  plex = config.modules.mounts.plex;
  kioku = config.modules.mounts.usb;
in
{
  fileSystems =
    {
      "/mnt/${kioku.name}" =
        let
          sharedOptions = [
            "x-systemd.automount"
            "noauto"
            "x-systemd.idle-timeout=60"
            "x-systemd.device-timeout=5s"
            "x-systemd.mount-timeout=5s"
            "rw"
            "nofail"
            "noatime"
            "uid=1000"
            "gid=1000"
          ];
        in
        if kioku.withSamba then
          {
            device = "//${kioku.name}/${kioku.shareName}";
            fsType = "cifs";

            options = [
              "credentials=${config.sops.secrets.samba_secrets.path}"
            ] ++ sharedOptions ++ kioku.extraOptions;
          }
        else
          {
            device = kioku.device;
            fsType = "exfat";
            options = sharedOptions;
          };
    }
    // (
      if plex.enable then
        {
          "/mnt/${plex.name}" = {
            device = "/dev/mapper/${plex.name}";
            fsType = "exfat";

            options = [
              "rw"
              "nofail"
              "uid=1000"
              "gid=1000"
              "dmask=027"
              "fmask=137"
            ] ++ plex.extraOptions;
          };
        }
      else
        { }
    );

  environment.etc.crypttab.text =
    if plex.enable then
      ''
        ${plex.name} /dev/disk/by-partlabel/WD_BLACK ${config.sops.secrets.plex_drive_bitlocker_recovery_key.path} bitlk
      ''
    else
      "";
}