diff --git a/modules/nixos/services/nas/audiobookshelf.nix b/modules/nixos/services/nas/audiobookshelf.nix new file mode 100644 index 0000000..ac35561 --- /dev/null +++ b/modules/nixos/services/nas/audiobookshelf.nix @@ -0,0 +1,29 @@ +{ + inputs, + config, + lib, + pkgs, + system, + ... +}: +let + cfg = config.services.nas; +in +{ + config = lib.mkIf (cfg.enable && cfg.servers.audiobookshelf.enable) { + + services.audiobookshelf = { + enable = true; + port = 63001; + }; + + services.traefik.dynamicConfigOptions = { + http.routers.audiobookshelf.entrypoints = "websecure"; + http.routers.audiobookshelf.tls = true; + http.routers.audiobookshelf.rule = "Host(`audiobookshelf.U3ncSovm`)"; + http.routers.audiobookshelf.service = "audiobookshelf"; + services.audiobookshelf.loadBalancer.servers = [ { url = "http://localhost:63001"; } ]; + }; + }; +} + diff --git a/modules/nixos/services/nas/default.nix b/modules/nixos/services/nas/default.nix new file mode 100644 index 0000000..4b76866 --- /dev/null +++ b/modules/nixos/services/nas/default.nix @@ -0,0 +1,29 @@ +{ inputs, config, lib, pkgs, ... }: +let + cfg = config.services.nas; +in +{ + imports = [ + ./traefik-proxy.nix + ./audiobookshelf.nix + ]; + + options.services.nas = { + enable = lib.mkOption { + type = with lib.types; uniq bool; + default = false; + description = "Enable NAS Server Configuration"; + }; + useTraefik.enable = lib.mkOption { + type = with lib.types; uniq bool; + default = true; + description = "Enables Traefik Reverese Proxy"; + }; + servers.audiobookshelf.enable = lib.mkOption { + type = with lib.types; uniq bool; + default = false; + description = "Audiobookshelf Server"; + }; + }; +} + diff --git a/modules/nixos/services/nas/traefik-proxy.nix b/modules/nixos/services/nas/traefik-proxy.nix new file mode 100644 index 0000000..ad946f1 --- /dev/null +++ b/modules/nixos/services/nas/traefik-proxy.nix @@ -0,0 +1,24 @@ +{ + inputs, + config, + lib, + pkgs, + system, + ... +}: +let + cfg = config.services.nas; +in +{ + config = lib.mkIf (cfg.enable && cfg.useTraefik.enable) { + + services.traefik = { + enable = true; + staticConfigOptions = { + entryPoints.web.address = ":80"; + entryPoints.websecure.address = ":443"; + }; + }; + }; +} + diff --git a/systems/x86_64-linux/U3ncSovm/default.nix b/systems/x86_64-linux/U3ncSovm/default.nix index fd7cf90..64727ab 100644 --- a/systems/x86_64-linux/U3ncSovm/default.nix +++ b/systems/x86_64-linux/U3ncSovm/default.nix @@ -45,6 +45,12 @@ git ]; + # Enable NAS Functionality + services.nas = { + enable = true; + servers.audiobookshelf = true; + }; + # SSH and Mosh services.openssh = { enable = true;