Commit 86dbce6d authored by Wietse de Vries's avatar Wietse de Vries Committed by Manuel Bärenz
Browse files

audiobookshelf: init module

parent 8d8e78c9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -87,6 +87,8 @@

- [tuxedo-rs](https://github.com/AaronErhardt/tuxedo-rs), Rust utilities for interacting with hardware from TUXEDO Computers.

- [audiobookshelf](https://github.com/advplyr/audiobookshelf/), a self-hosted audiobook and podcast server. Available as [services.audiobookshelf](#opt-services.audiobookshelf.enable).

## Backward Incompatibilities {#sec-release-23.11-incompatibilities}

- The `boot.loader.raspberryPi` options have been marked deprecated, with intent for removal for NixOS 24.11. They had a limited use-case, and do not work like people expect. They required either very old installs ([before mid-2019](https://github.com/NixOS/nixpkgs/pull/62462)) or customized builds out of scope of the standard and generic AArch64 support. That option set never supported the Raspberry Pi 4 family of devices.
+1 −0
Original line number Diff line number Diff line
@@ -1211,6 +1211,7 @@
  ./services/web-apps/atlassian/confluence.nix
  ./services/web-apps/atlassian/crowd.nix
  ./services/web-apps/atlassian/jira.nix
  ./services/web-apps/audiobookshelf.nix
  ./services/web-apps/bookstack.nix
  ./services/web-apps/calibre-web.nix
  ./services/web-apps/coder.nix
+90 −0
Original line number Diff line number Diff line
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.audiobookshelf;
in
{
  options = {
    services.audiobookshelf = {
      enable = mkEnableOption "Audiobookshelf, self-hosted audiobook and podcast server.";

      package = mkPackageOption pkgs "audiobookshelf" { };

      dataDir = mkOption {
        description = "Path to Audiobookshelf config and metadata inside of /var/lib.";
        default = "audiobookshelf";
        type = types.str;
      };

      host = mkOption {
        description = "The host Audiobookshelf binds to.";
        default = "127.0.0.1";
        example = "0.0.0.0";
        type = types.str;
      };

      port = mkOption {
        description = "The TCP port Audiobookshelf will listen on.";
        default = 8000;
        type = types.port;
      };

      user = mkOption {
        description = "User account under which Audiobookshelf runs.";
        default = "audiobookshelf";
        type = types.str;
      };

      group = mkOption {
        description = "Group under which Audiobookshelf runs.";
        default = "audiobookshelf";
        type = types.str;
      };

      openFirewall = mkOption {
        description = "Open ports in the firewall for the Audiobookshelf web interface.";
        default = false;
        type = types.bool;
      };
    };
  };

  config = mkIf cfg.enable {
    systemd.services.audiobookshelf = {
      description = "Audiobookshelf is a self-hosted audiobook and podcast server";

      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];

      serviceConfig = {
        Type = "simple";
        User = cfg.user;
        Group = cfg.group;
        StateDirectory = cfg.dataDir;
        WorkingDirectory = "/var/lib/${cfg.dataDir}";
        ExecStart = "${cfg.package}/bin/audiobookshelf --host ${cfg.host} --port ${toString cfg.port}";
        Restart = "on-failure";
      };
    };

    users.users = mkIf (cfg.user == "audiobookshelf") {
      audiobookshelf = {
        isSystemUser = true;
        group = cfg.group;
        home = "/var/lib/${cfg.dataDir}";
      };
    };

    users.groups = mkIf (cfg.group == "audiobookshelf") {
      audiobookshelf = { };
    };

    networking.firewall = mkIf cfg.openFirewall {
      allowedTCPPorts = [ cfg.port ];
    };
  };

  meta.maintainers = with maintainers; [ wietsedv ];
}
+1 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ in {
  atd = handleTest ./atd.nix {};
  atop = handleTest ./atop.nix {};
  atuin = handleTest ./atuin.nix {};
  audiobookshelf = handleTest ./audiobookshelf.nix {};
  auth-mysql = handleTest ./auth-mysql.nix {};
  authelia = handleTest ./authelia.nix {};
  avahi = handleTest ./avahi.nix {};
+23 −0
Original line number Diff line number Diff line
import ./make-test-python.nix ({ lib, ... }:

with lib;

{
  name = "audiobookshelf";
  meta.maintainers = with maintainers; [ wietsedv ];

  nodes.machine =
    { pkgs, ... }:
    {
      services.audiobookshelf = {
        enable = true;
        port = 1234;
      };
    };

  testScript = ''
    machine.wait_for_unit("audiobookshelf.service")
    machine.wait_for_open_port(1234)
    machine.succeed("curl --fail http://localhost:1234/")
  '';
})