nixos-config/services/navidrome.nix

76 lines
1.6 KiB
Nix
Raw Normal View History

2022-04-10 11:54:58 +02:00
{
config,
lib,
pkgs,
...
}: let
inherit
(lib)
2022-01-11 16:08:21 +01:00
mkEnableOption
mkIf
mkOption
optional
2022-04-10 11:54:58 +02:00
;
2022-01-11 16:08:21 +01:00
2021-08-22 16:40:57 +02:00
cfg = config.my.services.navidrome;
domain = config.networking.domain;
hostname = config.networking.hostName;
fqdn = "${hostname}.${domain}";
2021-08-22 16:40:57 +02:00
in {
2022-04-10 11:54:58 +02:00
options.my.services.navidrome = let
inherit (lib) types;
in {
2021-08-22 16:40:57 +02:00
enable = mkEnableOption "Navidrome";
musicFolder = {
path = mkOption {
type = types.str;
default = "./music";
};
backup = mkEnableOption "backup the music folder";
};
2021-08-22 16:40:57 +02:00
};
2022-01-11 16:08:21 +01:00
config = mkIf cfg.enable {
2021-08-22 16:40:57 +02:00
services.navidrome = {
enable = true;
settings = {
Address = "127.0.0.1";
Port = 4533;
LastFM.Enabled = false;
MusicFolder = cfg.musicFolder.path;
2021-08-22 16:40:57 +02:00
};
};
my.services.restic-backup = {
2022-04-10 11:54:58 +02:00
paths = ["/var/lib/navidrome"] ++ optional cfg.musicFolder.backup cfg.musicFolder.path;
exclude = ["/var/lib/navidrome/cache"];
};
2021-08-22 16:40:57 +02:00
services.nginx.virtualHosts."music.${domain}" = {
forceSSL = true;
useACMEHost = fqdn;
2021-08-22 16:40:57 +02:00
listen = [
# FIXME: hardcoded tailscale IP
{
addr = "100.80.61.67";
port = 443;
ssl = true;
}
{
addr = "100.80.61.67";
port = 80;
ssl = false;
}
];
locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.navidrome.settings.Port}/";
proxyWebsockets = true;
};
};
security.acme.certs.${fqdn}.extraDomainNames = ["music.${domain}"];
2021-08-22 16:40:57 +02:00
};
}