audiobookshelf: init module

authored by Wietse de Vries and committed by Manuel Bärenz 86dbce6d 8d8e78c9

+117
+2
nixos/doc/manual/release-notes/rl-2311.section.md
··· 87 87 88 88 - [tuxedo-rs](https://github.com/AaronErhardt/tuxedo-rs), Rust utilities for interacting with hardware from TUXEDO Computers. 89 89 90 + - [audiobookshelf](https://github.com/advplyr/audiobookshelf/), a self-hosted audiobook and podcast server. Available as [services.audiobookshelf](#opt-services.audiobookshelf.enable). 91 + 90 92 ## Backward Incompatibilities {#sec-release-23.11-incompatibilities} 91 93 92 94 - 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
nixos/modules/module-list.nix
··· 1211 1211 ./services/web-apps/atlassian/confluence.nix 1212 1212 ./services/web-apps/atlassian/crowd.nix 1213 1213 ./services/web-apps/atlassian/jira.nix 1214 + ./services/web-apps/audiobookshelf.nix 1214 1215 ./services/web-apps/bookstack.nix 1215 1216 ./services/web-apps/calibre-web.nix 1216 1217 ./services/web-apps/coder.nix
+90
nixos/modules/services/web-apps/audiobookshelf.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.audiobookshelf; 7 + in 8 + { 9 + options = { 10 + services.audiobookshelf = { 11 + enable = mkEnableOption "Audiobookshelf, self-hosted audiobook and podcast server."; 12 + 13 + package = mkPackageOption pkgs "audiobookshelf" { }; 14 + 15 + dataDir = mkOption { 16 + description = "Path to Audiobookshelf config and metadata inside of /var/lib."; 17 + default = "audiobookshelf"; 18 + type = types.str; 19 + }; 20 + 21 + host = mkOption { 22 + description = "The host Audiobookshelf binds to."; 23 + default = "127.0.0.1"; 24 + example = "0.0.0.0"; 25 + type = types.str; 26 + }; 27 + 28 + port = mkOption { 29 + description = "The TCP port Audiobookshelf will listen on."; 30 + default = 8000; 31 + type = types.port; 32 + }; 33 + 34 + user = mkOption { 35 + description = "User account under which Audiobookshelf runs."; 36 + default = "audiobookshelf"; 37 + type = types.str; 38 + }; 39 + 40 + group = mkOption { 41 + description = "Group under which Audiobookshelf runs."; 42 + default = "audiobookshelf"; 43 + type = types.str; 44 + }; 45 + 46 + openFirewall = mkOption { 47 + description = "Open ports in the firewall for the Audiobookshelf web interface."; 48 + default = false; 49 + type = types.bool; 50 + }; 51 + }; 52 + }; 53 + 54 + config = mkIf cfg.enable { 55 + systemd.services.audiobookshelf = { 56 + description = "Audiobookshelf is a self-hosted audiobook and podcast server"; 57 + 58 + after = [ "network.target" ]; 59 + wantedBy = [ "multi-user.target" ]; 60 + 61 + serviceConfig = { 62 + Type = "simple"; 63 + User = cfg.user; 64 + Group = cfg.group; 65 + StateDirectory = cfg.dataDir; 66 + WorkingDirectory = "/var/lib/${cfg.dataDir}"; 67 + ExecStart = "${cfg.package}/bin/audiobookshelf --host ${cfg.host} --port ${toString cfg.port}"; 68 + Restart = "on-failure"; 69 + }; 70 + }; 71 + 72 + users.users = mkIf (cfg.user == "audiobookshelf") { 73 + audiobookshelf = { 74 + isSystemUser = true; 75 + group = cfg.group; 76 + home = "/var/lib/${cfg.dataDir}"; 77 + }; 78 + }; 79 + 80 + users.groups = mkIf (cfg.group == "audiobookshelf") { 81 + audiobookshelf = { }; 82 + }; 83 + 84 + networking.firewall = mkIf cfg.openFirewall { 85 + allowedTCPPorts = [ cfg.port ]; 86 + }; 87 + }; 88 + 89 + meta.maintainers = with maintainers; [ wietsedv ]; 90 + }
+1
nixos/tests/all-tests.nix
··· 119 119 atd = handleTest ./atd.nix {}; 120 120 atop = handleTest ./atop.nix {}; 121 121 atuin = handleTest ./atuin.nix {}; 122 + audiobookshelf = handleTest ./audiobookshelf.nix {}; 122 123 auth-mysql = handleTest ./auth-mysql.nix {}; 123 124 authelia = handleTest ./authelia.nix {}; 124 125 avahi = handleTest ./avahi.nix {};
+23
nixos/tests/audiobookshelf.nix
··· 1 + import ./make-test-python.nix ({ lib, ... }: 2 + 3 + with lib; 4 + 5 + { 6 + name = "audiobookshelf"; 7 + meta.maintainers = with maintainers; [ wietsedv ]; 8 + 9 + nodes.machine = 10 + { pkgs, ... }: 11 + { 12 + services.audiobookshelf = { 13 + enable = true; 14 + port = 1234; 15 + }; 16 + }; 17 + 18 + testScript = '' 19 + machine.wait_for_unit("audiobookshelf.service") 20 + machine.wait_for_open_port(1234) 21 + machine.succeed("curl --fail http://localhost:1234/") 22 + ''; 23 + })