From 6c07c68c848e252fbf9f28c6b14ffd304b52f1b7 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 26 Aug 2024 12:54:38 -0400 Subject: [PATCH] Services: add Deluge --- flake.lock | 14 +++++----- hosts/Dimaga/default.nix | 7 +++++ modules/services/deluge.nix | 56 +++++++++++++++++++++++++++++++++++++ nix-secrets | 2 +- 4 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 modules/services/deluge.nix diff --git a/flake.lock b/flake.lock index c4cd5f1..f586646 100644 --- a/flake.lock +++ b/flake.lock @@ -234,11 +234,11 @@ "nix-secrets": { "flake": false, "locked": { - "lastModified": 1724432746, - "narHash": "sha256-s7XsY4ZsS9jyzZWpXOJNVzc03SNQbALM+S28QKXc8co=", + "lastModified": 1724691044, + "narHash": "sha256-5edUptO3EjmsvJuaVGI+hdGWRjCo4pBpn96s0bTawAU=", "ref": "refs/heads/main", - "rev": "56ccf5bf3f4d8687dc22c390cdafe20c08a7e549", - "revCount": 60, + "rev": "32d3f186c66df00253f80712c2c525616f5d6f25", + "revCount": 61, "type": "git", "url": "file:./nix-secrets" }, @@ -297,11 +297,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1724224976, - "narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=", + "lastModified": 1724479785, + "narHash": "sha256-pP3Azj5d6M5nmG68Fu4JqZmdGt4S4vqI5f8te+E/FTw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c374d94f1536013ca8e92341b540eba4c22f9c62", + "rev": "d0e1602ddde669d5beb01aec49d71a51937ed7be", "type": "github" }, "original": { diff --git a/hosts/Dimaga/default.nix b/hosts/Dimaga/default.nix index cb2dded..9ceef63 100644 --- a/hosts/Dimaga/default.nix +++ b/hosts/Dimaga/default.nix @@ -152,6 +152,13 @@ in user = config.users.users.aires.name; }; boinc.enable = true; + deluge = { + enable = true; + autostart = false; + home = "${services-root}/deluge"; + domain = config.secrets.networking.primaryDomain; + url = config.secrets.services.deluge.url; + }; duplicacy-web = { enable = true; autostart = false; diff --git a/modules/services/deluge.nix b/modules/services/deluge.nix new file mode 100644 index 0000000..41950b3 --- /dev/null +++ b/modules/services/deluge.nix @@ -0,0 +1,56 @@ +# This is an example of a blank module. +{ config, lib, ... }: + +let + cfg = config.aux.system.services.deluge; +in +{ + options = { + aux.system.services.deluge = { + autostart = lib.mkEnableOption "Automatically starts Deluge at boot."; + enable = lib.mkEnableOption "Enables Deluge."; + home = lib.mkOption { + default = ""; + type = lib.types.str; + description = "Where to store Deluge's files"; + }; + domain = lib.mkOption { + default = ""; + type = lib.types.str; + description = "The root domain that Deluge will be hosted on."; + example = "example.com"; + }; + url = lib.mkOption { + default = ""; + type = lib.types.str; + description = "The complete URL where Deluge is hosted."; + example = "https://deluge.example.com"; + }; + }; + + }; + + config = lib.mkIf cfg.enable { + services = { + nginx.virtualHosts."${cfg.url}" = { + useACMEHost = cfg.domain; + forceSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:8112"; + extraConfig = '' + proxy_set_header X-Deluge-Base "/"; + add_header X-Frame-Options SAMEORIGIN; + ''; + }; + }; + deluge = { + enable = true; + dataDir = cfg.home; + web = { + enable = true; + openFirewall = false; # Not needed since we're using a reverse proxy + }; + }; + }; + }; +} diff --git a/nix-secrets b/nix-secrets index 56ccf5b..32d3f18 160000 --- a/nix-secrets +++ b/nix-secrets @@ -1 +1 @@ -Subproject commit 56ccf5bf3f4d8687dc22c390cdafe20c08a7e549 +Subproject commit 32d3f186c66df00253f80712c2c525616f5d6f25