From e6876d95d12f95c6e9ca9301e4d0388d386312b6 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 2 Jan 2022 21:55:09 +0100 Subject: [PATCH] Add mixcloud mirror --- hosts/storage-2/configuration.nix | 5 ++++ hosts/storage-2/mixcloud.nix | 39 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 hosts/storage-2/mixcloud.nix diff --git a/hosts/storage-2/configuration.nix b/hosts/storage-2/configuration.nix index 164df34..899aeff 100644 --- a/hosts/storage-2/configuration.nix +++ b/hosts/storage-2/configuration.nix @@ -6,6 +6,7 @@ ./hardware-configuration.nix ../../configuration/common ../../configuration/proxmox-vm + ./mixcloud.nix ]; boot.loader.grub.enable = true; @@ -23,6 +24,10 @@ networking.defaultGateway6 = { address = "2001:638:904:ffc0::1"; interface = "ens18"; }; networking.nameservers = [ "2001:638:904:ffcc::3" "2001:638:904:ffcc::4" "141.24.40.3" "141.24.40.4" ]; + services.nginx.enable = true; + + networking.firewall.allowedTCPPorts = [ 80 443 ]; + clerie.monitoring = { enable = true; id = "209"; diff --git a/hosts/storage-2/mixcloud.nix b/hosts/storage-2/mixcloud.nix new file mode 100644 index 0000000..be7fa47 --- /dev/null +++ b/hosts/storage-2/mixcloud.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: + +{ + services.nginx.virtualHosts = { + "mixcloud.clerie.de" = { + enableACME = true; + forceSSL = true; + locations."/" = { + alias = "/data/mixcloud/"; + basicAuthFile = "/var/src/secrets/nginx/mixcloud.htpasswd"; + extraConfig = '' + autoindex on; + ''; + }; + }; + }; + + users.users.data-mixcloud = { + group = "data-mixcloud"; + home = "/data/mixcloud"; + useDefaultShell = true; + isSystemUser = true; + }; + users.groups.data-mixcloud = {}; + + systemd.services."youtube-dl-mixcloud-couchsofa" = { + serviceConfig = { + User = "data-mixcloud"; + Group = "data-mixcloud"; + }; + path = [ pkgs.youtube-dl ]; + script = '' + mkdir -p /data/mixcloud/couchsofa/ + cd /data/mixcloud/couchsofa/ + youtube-dl https://www.mixcloud.com/couchsofa/ + ''; + startAt = "*-*-* 05:05:00"; + }; +}