arr: add declarative api key

This commit is contained in:
ibizaman 2026-02-23 21:38:09 +01:00 committed by Pierre Penninckx
parent 54d9be7783
commit 0d2a7c315f
2 changed files with 28 additions and 12 deletions

View file

@ -144,6 +144,10 @@ let
description = "Log level.";
default = "info";
};
ApiKey = lib.mkOption {
type = shb.secretFileType;
description = "Path to api key secret file.";
};
Port = lib.mkOption {
type = lib.types.port;
description = "Port on which bazarr listens to incoming requests.";
@ -172,6 +176,10 @@ let
description = "Log level.";
default = "info";
};
ApiKey = lib.mkOption {
type = shb.secretFileType;
description = "Path to api key secret file.";
};
Port = lib.mkOption {
type = lib.types.port;
description = "Port on which readarr listens to incoming requests.";
@ -199,6 +207,10 @@ let
description = "Log level.";
default = "info";
};
ApiKey = lib.mkOption {
type = shb.secretFileType;
description = "Path to api key secret file.";
};
Port = lib.mkOption {
type = lib.types.port;
description = "Port on which lidarr listens to incoming requests.";
@ -458,16 +470,20 @@ in
users.users.bazarr = {
extraGroups = [ "media" ];
};
systemd.services.bazarr.preStart = shb.replaceSecrets {
userConfig =
cfg'.settings
// (lib.optionalAttrs isSSOEnabled {
AuthenticationRequired = "DisabledForLocalAddresses";
AuthenticationMethod = "External";
});
resultPath = "${cfg'.dataDir}/config.xml";
generator = apps.bazarr.settingsFormat.generate;
};
# This is actually not working. Bazarr uses a config file in dataDir/config/config.yaml
# which includes all configuration so we must somehow merge our declarative config with it.
# It's doable but will take some time. Help is welcomed.
#
# systemd.services.bazarr.preStart = shb.replaceSecrets {
# userConfig =
# cfg'.settings
# // (lib.optionalAttrs isSSOEnabled {
# AuthenticationRequired = "DisabledForLocalAddresses";
# AuthenticationMethod = "External";
# });
# resultPath = "${cfg'.dataDir}/config.xml";
# generator = apps.bazarr.settingsFormat.generate;
# };
shb.nginx.vhosts = [ (vhosts { } cfg') ];
}

View file

@ -51,7 +51,7 @@ let
if response['code'] != 200:
raise Exception(f"Code is {response['code']}")
''
+ lib.optionalString (apiKey != null) ''
+ lib.optionalString (apiKey != null && cfgPath != null) ''
with subtest("apikey"):
config = server.succeed("cat ${cfgPath}")
@ -212,7 +212,7 @@ let
radarrCfgFn = cfg: "${cfg.dataDir}/config.xml";
sonarrCfgFn = cfg: "${cfg.dataDir}/config.xml";
bazarrCfgFn = cfg: "${cfg.dataDir}/config.xml";
bazarrCfgFn = cfg: null;
readarrCfgFn = cfg: "${cfg.dataDir}/config.xml";
lidarrCfgFn = cfg: "${cfg.dataDir}/config.xml";
jackettCfgFn = cfg: "${cfg.dataDir}/ServerConfig.json";