From 318eda3b4acf605861e537ce7dbb0f21f618b1b2 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sat, 8 Jun 2024 10:19:47 -0400 Subject: [PATCH] containers: added native nix audiobookshelf container --- .../nixos/audiobookshelf/default.nix | 47 +++++++++++++++++++ nixosModules/containers/nixos/default.nix | 5 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 nixosModules/containers/nixos/audiobookshelf/default.nix diff --git a/nixosModules/containers/nixos/audiobookshelf/default.nix b/nixosModules/containers/nixos/audiobookshelf/default.nix new file mode 100644 index 00000000..6e81dfd8 --- /dev/null +++ b/nixosModules/containers/nixos/audiobookshelf/default.nix @@ -0,0 +1,47 @@ +{ + pkgs, + lib, + config, + ... +}: { + options = { + alyraffauf.containers.nixos.audiobookshelf = { + enable = + lib.mkEnableOption "Enable audiobookshelf nixos container."; + mediaDirectory = lib.mkOption { + description = "Media directory for Audiobookshelf."; + default = "/mnt/Media"; + type = lib.types.str; + }; + port = lib.mkOption { + description = "Port for audiobookshelf."; + default = 13378; + type = lib.types.int; + }; + }; + }; + + config = lib.mkIf config.alyraffauf.containers.nixos.audiobookshelf.enable { + containers.audiobookshelf = { + autoStart = true; + bindMounts."/Media".hostPath = config.alyraffauf.containers.nixos.audiobookshelf.mediaDirectory; + config = let + port = config.alyraffauf.containers.nixos.audiobookshelf.port; + in + { + config, + lib, + pkgs, + ... + }: { + system.stateVersion = "24.05"; + services.audiobookshelf = { + enable = true; + openFirewall = true; + host = "0.0.0.0"; + port = port; + }; + }; + }; + }; +} diff --git a/nixosModules/containers/nixos/default.nix b/nixosModules/containers/nixos/default.nix index 7a32ccaa..8bdaf2e3 100644 --- a/nixosModules/containers/nixos/default.nix +++ b/nixosModules/containers/nixos/default.nix @@ -4,5 +4,8 @@ config, ... }: { - imports = [./navidrome]; + imports = [ + ./audiobookshelf + ./navidrome + ]; }