aboutsummaryrefslogtreecommitdiff
path: root/nixos/configurations/ridcully.nix
blob: 9f3ed573a6ef8e995f8901e1bc97498fb924adc8 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{pkgs, ...}: {
  system.stateVersion = "24.05";
  nixpkgs.hostPlatform.system = "x86_64-linux";
  deploy.enable = true;

  cynerd = {
    desktop.enable = true;
    develop = true;
    gaming = true;
    openvpn = {
      elektroline = true;
    };
    borgjobs = {
      hetzner-s3.paths = "/back/hetzner-s3-sync";
    };
  };

  boot.initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"];
  boot.kernelModules = ["kvm-amd"];

  hardware.cpu.amd.updateMicrocode = true;
  services.hardware.openrgb.motherboard = "amd";

  zramSwap = {
    enable = true;
    memoryPercent = 50;
  };

  cynerd.autounlock = {
    "encroot" = "/dev/disk/by-uuid/bc7d2ba4-6e04-4c49-b40c-3aecd1a86c71";
    "enchdd" = "/dev/disk/by-uuid/7fee3cda-efa0-47cd-8832-fdead9a7e6db";
    "encback" = "/dev/disk/by-uuid/b426cbe7-fba2-473b-90f9-9ebe3e34b76e";
  };
  fileSystems = {
    "/" = {
      device = "/dev/mapper/encroot";
      fsType = "btrfs";
      options = ["compress=lzo" "subvol=@nix"];
    };
    "/home" = {
      device = "/dev/mapper/encroot";
      fsType = "btrfs";
      options = ["compress=lzo" "subvol=@home"];
    };
    "/boot" = {
      device = "/dev/disk/by-uuid/6DAD-3819";
      fsType = "vfat";
    };

    "/home2" = {
      device = "/dev/mapper/enchdd";
      fsType = "btrfs";
      options = ["compress=lzo" "subvol=@home"];
    };
    "/back" = {
      device = "/dev/mapper/encback";
      fsType = "btrfs";
      options = ["compress=lzo"];
    };
  };
  services.btrfs.autoScrub = {
    enable = true;
    fileSystems = ["/" "/home2"];
  };

  networking = {
    useNetworkd = true;
    useDHCP = true;
  };
  systemd.network = {
    wait-online.enable = false;
  };

  environment.systemPackages = [
    pkgs.nvtopPackages.amd
    #sbctl
  ];

  # Force nix to use less jobs
  nix.settings.max-jobs = 4;

  ##############################################################################
  services = {
    syncthing = {
      enable = true;
      dataDir = "/home/cynerd";
    };

    octoprint = {
      enable = true;
      openFirewall = true;
    };

    mjpg-streamer = {
      enable = true;
      inputPlugin = "input_uvc.so -d /dev/video2 -r 1920x1080 -f 30";
      outputPlugin = "output_http.so -p 5001 -w @www@";
    };
  };
  networking.firewall.allowedTCPPorts = [5001];

  # Service to synchronize local copy of Hetzner S3
  systemd = {
    services."hetzner-sync" = {
      script = ''
        /run/current-system/sw/bin/rclone --config /run/secrets/rclone-hetzner.conf \
          sync hetzner: /back/hetzner-s3-sync
      '';
      serviceConfig = {
        Type = "oneshot";
        User = "root";
      };
    };
    timers."hetzner-sync" = {
      wantedBy = ["timers.target"];
      timerConfig.Unit = "hetzner-sync.service";
      timerConfig = {
        OnCalendar = "daily";
        Persistent = false;
      };
    };
  };
}