diff --git a/hosts/dingserver/caddy.nix b/hosts/dingserver/caddy.nix index 8ef6621..e54cad3 100644 --- a/hosts/dingserver/caddy.nix +++ b/hosts/dingserver/caddy.nix @@ -68,6 +68,12 @@ file_server ''; }; + + "movies.danielpatterson.dev" = { + extraConfig = '' + reverse_proxy localhost:8096 + ''; + }; }; }; } diff --git a/hosts/dingserver/configuration.nix b/hosts/dingserver/configuration.nix index c27d84e..61ffddd 100644 --- a/hosts/dingserver/configuration.nix +++ b/hosts/dingserver/configuration.nix @@ -9,8 +9,9 @@ ../common ./hardware-configuration.nix ./caddy.nix - ./synapse.nix ./prometheus.nix + ./rclone.nix + ./synapse.nix ./tmux.nix ]; @@ -34,6 +35,8 @@ }; }; + services.jellyfin.enable = true; + environment.systemPackages = with pkgs; [ helix kitty # For terminfo diff --git a/hosts/dingserver/rclone.nix b/hosts/dingserver/rclone.nix new file mode 100644 index 0000000..17b46d8 --- /dev/null +++ b/hosts/dingserver/rclone.nix @@ -0,0 +1,38 @@ +{ + pkgs, + config, + ... +}: let + mountdir = "/var/media/dungflix"; + + file = '' + [dungflix] + type = b2 + ''; +in { + age.secrets = { + dungflix_bucket_account_id.file = ../../secrets/dungflix_bucket_account_id.age; + dungflix_bucket_account_key.file = ../../secrets/dungflix_bucket_account_key.age; + }; + systemd.services.dungflix-mount = { + description = "Mount the Backblaze B2 media store"; + wantedBy = ["multi-user.target"]; + path = [pkgs.fuse]; + preStart = '' + mkdir -p -m 777 ${mountdir} + ''; + script = '' + export RCLONE_B2_ACCOUNT=''$(cat ${config.age.secrets.dungflix_bucket_account_id.path}) + export RCLONE_B2_KEY=''$(cat ${config.age.secrets.dungflix_bucket_account_key.path}) + ${pkgs.rclone}/bin/rclone --config="${pkgs.writeText "" file}" mount dungflix:dungflix-bucket ${mountdir} \ + --vfs-cache-mode full \ + --vfs-cache-max-age 48h \ + --vfs-cache-max-size 100G \ + --allow-other \ + --no-modtime \ + --buffer-size 2G \ + -vvv + ''; + postStop = "fusermount -u ${mountdir}"; + }; +}