{ config, pkgs, ... }:

{
  imports = [
    ./hardware-configuration.nix
    ../../base.nix
    ../../users/root.nix
    ../../roles/tailscale.nix
    ../../roles/caddy.nix
    ../../roles/vscode-remote.nix
    ../../roles/syncthing.nix
  ];

  services.openssh.openFirewall = false;

  boot.tmp.cleanOnBoot = true;
  zramSwap.enable = true;
  networking.hostName = "garden";

  # Enable the Flakes feature and the accompanying new nix command-line tool
  nix.settings.experimental-features = [
    "nix-command"
    "flakes"
  ];

  services.syncthing.group = config.services.lidarr.group;
  services.caddy.virtualHosts."https://media.tailc50184.ts.net".extraConfig = ''
    bind tailscale/media
    reverse_proxy localhost:8384 {
      header_up Host {upstream_hostport}
    }
  '';

  services.prowlarr.enable = true;
  services.caddy.virtualHosts."https://prowlarr.tailc50184.ts.net".extraConfig = ''
    bind tailscale/prowlarr
    reverse_proxy http://localhost:9696
  '';

  services.lidarr.enable = true;
  services.caddy.virtualHosts."https://lidarr.tailc50184.ts.net".extraConfig = ''
    bind tailscale/lidarr
    reverse_proxy http://localhost:8686
  '';

  services.transmission = {
    enable = true;
    group = config.services.lidarr.group;
  };

  environment.systemPackages = with pkgs; [
    flac
    shntool
  ];

  system.stateVersion = "23.11";
}