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";
externalCacheDir = "/var/cache/copyparty";
externalStateDir = "/var/lib/copyparty";
defaultShareDir = "${externalCacheDir}/data";
defaultShareDir = "${externalStateDir}/data";
in {
options.services.copyparty = {
enable = mkEnableOption "web-based file manager";
@ -163,7 +163,7 @@ in {
type = types.attrsOf (types.submodule ({...}: {
options = {
path = mkOption {
type = types.str;
type = types.path;
description = ''
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.users.copyparty = lib.mkIf (cfg.user == "copyparty" && cfg.group == "copyparty") {
description = "Service user for copyparty";