nixos/navidrome: ensure data & cache dirs exist with valid permissions
This commit is contained in:
parent
ffc0d8bf58
commit
7519d230b5
1 changed files with 65 additions and 54 deletions
|
@ -6,11 +6,7 @@
|
|||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
;
|
||||
inherit (lib) mkEnableOption mkPackageOption mkOption;
|
||||
inherit (lib.types) bool str;
|
||||
cfg = config.services.navidrome;
|
||||
settingsFormat = pkgs.formats.json { };
|
||||
|
@ -58,9 +54,21 @@ in
|
|||
config =
|
||||
let
|
||||
inherit (lib) mkIf optional getExe;
|
||||
WorkingDirectory = "/var/lib/navidrome";
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
systemd.services.navidrome = {
|
||||
systemd = {
|
||||
tmpfiles.settings.navidromeDirs = {
|
||||
"${cfg.settings.DataFolder or WorkingDirectory}"."d" = {
|
||||
mode = "700";
|
||||
inherit (cfg) user group;
|
||||
};
|
||||
"${cfg.settings.CacheFolder or (WorkingDirectory + "/cache")}"."d" = {
|
||||
mode = "700";
|
||||
inherit (cfg) user group;
|
||||
};
|
||||
};
|
||||
services.navidrome = {
|
||||
description = "Navidrome Media Server";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
@ -71,11 +79,13 @@ in
|
|||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
StateDirectory = "navidrome";
|
||||
WorkingDirectory = "/var/lib/navidrome";
|
||||
inherit WorkingDirectory;
|
||||
RuntimeDirectory = "navidrome";
|
||||
RootDirectory = "/run/navidrome";
|
||||
ReadWritePaths = "";
|
||||
BindPaths = optional (cfg.settings ? DataFolder) cfg.settings.DataFolder;
|
||||
BindPaths =
|
||||
optional (cfg.settings ? DataFolder) cfg.settings.DataFolder
|
||||
++ optional (cfg.settings ? CacheFolder) cfg.settings.CacheFolder;
|
||||
BindReadOnlyPaths = [
|
||||
# navidrome uses online services to download additional album metadata / covers
|
||||
"${
|
||||
|
@ -111,6 +121,7 @@ in
|
|||
ProtectHostname = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
users.users = mkIf (cfg.user == "navidrome") {
|
||||
navidrome = {
|
||||
|
|
Loading…
Reference in a new issue