homepage: audiobookshelf init
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{ lib, config, pkgs, ... }:
|
||||
let
|
||||
setup = import ./servers/base.nix { inherit lib config; };
|
||||
serviceBase = {
|
||||
enable = true;
|
||||
group = "piracy";
|
||||
@@ -43,7 +44,7 @@ in {
|
||||
./servers/adguardhome.nix
|
||||
./servers/paperless.nix
|
||||
./servers/postgres.nix
|
||||
(import ./servers/audiobookshelf.nix { inherit lib config proxy; })
|
||||
(import ./servers/audiobookshelf.nix { inherit lib config proxy setup; })
|
||||
(import ./servers/bazarr.nix {
|
||||
inherit lib config serviceBase proxyReverse;
|
||||
})
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
{ lib, config, proxy, ... }: {
|
||||
options.my.servers.audiobookshelf.enable = lib.mkEnableOption "enable";
|
||||
{ lib, config, proxy, setup, ... }:
|
||||
let cfg = config.my.servers.audiobookshelf;
|
||||
in {
|
||||
options.my.servers.audiobookshelf =
|
||||
setup.mkServerOptions "audiobookshelf" "audiobooks" 5687;
|
||||
config = lib.mkIf config.my.servers.audiobookshelf.enable {
|
||||
services = {
|
||||
audiobookshelf = {
|
||||
enable = true;
|
||||
group = "piracy";
|
||||
port = 5687;
|
||||
port = cfg.port;
|
||||
};
|
||||
nginx = {
|
||||
enable = true;
|
||||
virtualHosts."audiobooks.${config.my.domain}" = proxy {
|
||||
virtualHosts."${cfg.host}" = proxy {
|
||||
"/" = {
|
||||
proxyPass = "http://${config.my.localhost}:${
|
||||
toString config.services.audiobookshelf.port
|
||||
}";
|
||||
proxyPass = cfg.local;
|
||||
extraConfig = ''
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
23
modules/servers/base.nix
Normal file
23
modules/servers/base.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
mkServerOptions = name: subdomain: port: {
|
||||
enable = lib.mkEnableOption "enable";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = port;
|
||||
};
|
||||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "${subdomain}.${config.my.domain}";
|
||||
};
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "https://${config.my.servers.${name}.host}";
|
||||
};
|
||||
local = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "http://${config.my.localhost}:${toString port}";
|
||||
};
|
||||
};
|
||||
in { inherit mkServerOptions; }
|
||||
@@ -3,11 +3,46 @@ let port = 8082;
|
||||
in {
|
||||
options.my.servers.homepage.enable = lib.mkEnableOption "enable";
|
||||
config = lib.mkIf config.my.servers.homepage.enable {
|
||||
# sops.secrets.homepage.sopsFile = ../../secrets/env.yaml;
|
||||
sops.secrets.homepage.sopsFile = ../../secrets/env.yaml;
|
||||
services = {
|
||||
homepage-dashboard = {
|
||||
enable = true;
|
||||
listenPort = port;
|
||||
environmentFile = config.sops.secrets.homepage.path;
|
||||
settings = {
|
||||
background =
|
||||
"https://images.unsplash.com/photo-1502790671504-542ad42d5189?auto=format&fit=crop&w=2560&q=80";
|
||||
};
|
||||
widgets = [
|
||||
{
|
||||
resources = {
|
||||
cpu = true;
|
||||
cputemp = true;
|
||||
units = "metric";
|
||||
disk = "/";
|
||||
memory = true;
|
||||
};
|
||||
}
|
||||
{
|
||||
search = {
|
||||
provider = [ "brave" "bing" "google" ];
|
||||
target = "_blank";
|
||||
showSearchSuggestions = true;
|
||||
};
|
||||
}
|
||||
];
|
||||
services = [{
|
||||
"Multimedia" = [{
|
||||
Audiobookshelf = lib.mkIf config.my.servers.audiobookshelf.enable {
|
||||
href = config.my.servers.audiobookshelf.url;
|
||||
widget = {
|
||||
type = "audiobookshelf";
|
||||
url = config.my.servers.audiobookshelf.local;
|
||||
key = "{{HOMEPAGE_VAR_AUDIOBOOKSHELF}}";
|
||||
};
|
||||
};
|
||||
}];
|
||||
}];
|
||||
};
|
||||
nginx = {
|
||||
enable = true;
|
||||
|
||||
Reference in New Issue
Block a user