refactor(copyparty): move volume defaults to service

This commit is contained in:
2026-10-13 11:27:47 -04:00
parent 161103ad7c
commit 96006c7236
3 changed files with 82 additions and 82 deletions

View File

@@ -5,11 +5,8 @@
}:
let
cfg = config.guests.copyparty; # NOLINT(let_order)
accountName = config.user.name;
volumeType = lib.types.submodule (
{ config, ... }:
{
volumeType = lib.types.submodule {
options = {
hostPath = lib.mkOption {
type = lib.types.str;
@@ -23,7 +20,7 @@ let
access = lib.mkOption {
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
default.A = [ accountName ];
default = { };
description = "Copyparty access map from permission string to account names.";
};
@@ -35,20 +32,11 @@ let
flags = lib.mkOption {
type = lib.types.attrs;
default =
if config.readOnly then
{ }
else
{
d2d = true;
d2t = true;
dthumb = true;
};
default = { };
description = "Copyparty volume flags.";
};
};
}
);
};
stateDir = "/var/lib/copyparty";
in
{
@@ -108,14 +96,17 @@ in
enable = cfg.reverseProxy.enable;
inherit (cfg.reverseProxy) trustedSources;
};
volumes = lib.mapAttrs (_urlPath: volume: {
volumes = lib.mapAttrs (
_urlPath: volume:
{
inherit (volume)
path
access
flags
readOnly
;
}) cfg.volumes;
}
// lib.optionalAttrs (volume.access != { }) { inherit (volume) access; }
// lib.optionalAttrs (volume.flags != { }) { inherit (volume) flags; }
) cfg.volumes;
};
mounts = {

View File

@@ -129,7 +129,6 @@
"/" = {
hostPath = "/pikachu/data/copyparty/root";
path = "/srv";
access.r = [ config.user.name ];
readOnly = true;
};
"/inbox" = {
@@ -143,7 +142,6 @@
"/opds" = {
hostPath = "/pikachu/data/opds";
path = "/pikachu/data/opds";
access.r = [ config.user.name ];
readOnly = true;
flags.opds = true;
};

View File

@@ -8,6 +8,8 @@
let
cfg = config.modules.services.copyparty; # NOLINT(let_order)
accountName = config.user.name;
serviceGroup = "storage";
serviceStateDir = "/var/lib/copyparty";
@@ -18,8 +20,6 @@ let
port = 3923;
accountName = config.user.name;
credentialName = "password-${builtins.substring 0 16 (builtins.hashString "sha256" accountName)}";
passwordPlaceholder = "@COPYPARTY_PASSWORD_${
@@ -89,7 +89,9 @@ in
volumes = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule {
lib.types.submodule (
{ config, ... }:
{
options = {
path = lib.mkOption {
type = lib.types.externalPath;
@@ -98,7 +100,7 @@ in
access = lib.mkOption {
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
default = { };
default = if config.readOnly then { r = [ accountName ]; } else { A = [ accountName ]; };
example = {
A = [ "alexion" ];
};
@@ -113,7 +115,15 @@ in
flags = lib.mkOption {
type = lib.types.attrs;
default = { };
default =
if config.readOnly then
{ }
else
{
d2d = true;
d2t = true;
dthumb = true;
};
example = {
dthumb = true;
};
@@ -121,6 +131,7 @@ in
};
};
}
)
);
default = { };
description = "Defines Copyparty volumes by URL path.";