From 2dedb41a47e83aa3a86b4ad8062d7348fa7a35c9 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 21 Mar 2024 19:59:34 +0100 Subject: [PATCH] nixos: services: add audiobookshelf --- .../nixos/services/audiobookshelf/default.nix | 39 +++++++++++++++++++ modules/nixos/services/default.nix | 1 + 2 files changed, 40 insertions(+) create mode 100644 modules/nixos/services/audiobookshelf/default.nix diff --git a/modules/nixos/services/audiobookshelf/default.nix b/modules/nixos/services/audiobookshelf/default.nix new file mode 100644 index 0000000..8c9719d --- /dev/null +++ b/modules/nixos/services/audiobookshelf/default.nix @@ -0,0 +1,39 @@ +# Audiobook and podcast library +{ config, lib, ... }: +let + cfg = config.my.services.audiobookshelf; +in +{ + options.my.services.audiobookshelf = with lib; { + enable = mkEnableOption "Audiobookshelf, a self-hosted podcast manager"; + + port = mkOption { + type = types.port; + default = 8000; + example = 4242; + description = "The port on which Audiobookshelf will listen for incoming HTTP traffic."; + }; + }; + + config = lib.mkIf cfg.enable { + services.audiobookshelf = { + enable = true; + inherit (cfg) port; + + group = "media"; + }; + + # Set-up media group + users.groups.media = { }; + + my.services.nginx.virtualHosts = { + audiobookshelf = { + inherit (cfg) port; + # Proxy websockets for RPC + extraConfig = { + locations."/".proxyWebsockets = true; + }; + }; + }; + }; +} diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index 3b32d06..60b2478 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -4,6 +4,7 @@ imports = [ ./adblock ./aria + ./audiobookshelf ./backup ./blog ./calibre-web