made systemd.tmpfiles rules to ensure the volume directories exist.

This commit is contained in:
Gabe Venberg 2025-04-24 23:52:39 +02:00
parent a90293626d
commit 9ce4839cf2

View file

@ -56,7 +56,7 @@ with lib; let
runtimeConfigPath = "/run/copyparty/copyparty.conf"; runtimeConfigPath = "/run/copyparty/copyparty.conf";
externalCacheDir = "/var/cache/copyparty"; externalCacheDir = "/var/cache/copyparty";
externalStateDir = "/var/lib/copyparty"; externalStateDir = "/var/lib/copyparty";
defaultShareDir = "${externalCacheDir}/data"; defaultShareDir = "${externalStateDir}/data";
in { in {
options.services.copyparty = { options.services.copyparty = {
enable = mkEnableOption "web-based file manager"; enable = mkEnableOption "web-based file manager";
@ -163,7 +163,7 @@ in {
type = types.attrsOf (types.submodule ({...}: { type = types.attrsOf (types.submodule ({...}: {
options = { options = {
path = mkOption { path = mkOption {
type = types.str; type = types.path;
description = '' description = ''
Path of a directory to share. Path of a directory to share.
''; '';
@ -330,6 +330,20 @@ in {
}; };
}; };
# ensure volumes exist:
systemd.tmpfiles.settings."copyparty" = (
lib.attrsets.mapAttrs' (
name: value: lib.attrsets.nameValuePair (value.path) ({
d={
#: in front of things means it wont change it if the directory already exists.
group = ":${cfg.group}";
user = ":${cfg.user}";
mode = ":755";
};
})
) cfg.volumes
);
users.groups.copyparty = lib.mkIf (cfg.user == "copyparty" && cfg.group == "copyparty") {}; users.groups.copyparty = lib.mkIf (cfg.user == "copyparty" && cfg.group == "copyparty") {};
users.users.copyparty = lib.mkIf (cfg.user == "copyparty" && cfg.group == "copyparty") { users.users.copyparty = lib.mkIf (cfg.user == "copyparty" && cfg.group == "copyparty") {
description = "Service user for copyparty"; description = "Service user for copyparty";