From f55e94ad4c58ca59d32e17dca66eee43316da2c8 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 26 Dec 2024 00:13:42 +0000 Subject: [PATCH] Make audiobookshelf togglable per host --- .../nixos/features/homelab/audiobookshelf.nix | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/nix/modules/nixos/features/homelab/audiobookshelf.nix b/nix/modules/nixos/features/homelab/audiobookshelf.nix index a5919aa..54aabb7 100644 --- a/nix/modules/nixos/features/homelab/audiobookshelf.nix +++ b/nix/modules/nixos/features/homelab/audiobookshelf.nix @@ -1,20 +1,29 @@ -{ config, ... }: +{ config, lib, ... }: +with lib; + +let + cfg = config.features.homelab.audiobookshelf; +in { - services.audiobookshelf = { - enable = true; + options.features.homelab.audiobookshelf.enable = mkEnableOption "Enable audiobookshelf"; - host = "audiobookshelf.davies.home"; - port = 4001; - }; + config = mkIf cfg.enable { + services.audiobookshelf = { + enable = true; - services.nginx = { - enable = true; + host = "audiobookshelf.davies.home"; + port = 4001; + }; - virtualHosts."audiobookshelf.davies.home" = { - locations."/" = { - proxyPass = "http://localhost:${toString config.services.audiobookshelf.port}/"; - proxyWebsockets = true; + services.nginx = { + enable = true; + + virtualHosts."audiobookshelf.davies.home" = { + locations."/" = { + proxyPass = "http://localhost:${toString config.services.audiobookshelf.port}/"; + proxyWebsockets = true; + }; }; }; };