1 { config, lib, pkgs, ... }:
6 cfg = config.services.audiobookshelf;
10 services.audiobookshelf = {
11 enable = mkEnableOption "Audiobookshelf, self-hosted audiobook and podcast server";
13 package = mkPackageOption pkgs "audiobookshelf" { };
16 description = "Path to Audiobookshelf config and metadata inside of /var/lib.";
17 default = "audiobookshelf";
22 description = "The host Audiobookshelf binds to.";
23 default = "127.0.0.1";
29 description = "The TCP port Audiobookshelf will listen on.";
35 description = "User account under which Audiobookshelf runs.";
36 default = "audiobookshelf";
41 description = "Group under which Audiobookshelf runs.";
42 default = "audiobookshelf";
46 openFirewall = mkOption {
47 description = "Open ports in the firewall for the Audiobookshelf web interface.";
54 config = mkIf cfg.enable {
55 systemd.services.audiobookshelf = {
56 description = "Audiobookshelf is a self-hosted audiobook and podcast server";
58 after = [ "network.target" ];
59 wantedBy = [ "multi-user.target" ];
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";
72 users.users = mkIf (cfg.user == "audiobookshelf") {
76 home = "/var/lib/${cfg.dataDir}";
80 users.groups = mkIf (cfg.group == "audiobookshelf") {
84 networking.firewall = mkIf cfg.openFirewall {
85 allowedTCPPorts = [ cfg.port ];
89 meta.maintainers = with maintainers; [ wietsedv ];