refactor(copyparty): remove unused wrapper options

This commit is contained in:
2026-10-12 22:41:32 -04:00
parent 372c19387a
commit 7a1086ef3b
3 changed files with 28 additions and 62 deletions

View File

@@ -6,46 +6,24 @@
}:
let
cfg = config.modules.services.copyparty; # NOLINT(let_order)
port = 3923;
serviceGroup = "storage";
serviceStateDir = "/var/lib/copyparty";
serviceUser = "copyparty";
in
{
options.modules.services.copyparty = {
enable = lib.mkEnableOption "Copyparty";
port = lib.mkOption {
type = lib.types.port;
default = 3923;
description = "Sets the TCP port that Copyparty listens on.";
};
user = lib.mkOption {
type = lib.types.str;
default = "copyparty";
description = "Sets the user that runs Copyparty.";
};
group = lib.mkOption {
type = lib.types.str;
default = "storage";
description = "Sets the group that owns Copyparty state and served files.";
};
accountName = lib.mkOption {
type = lib.types.str;
default = "alexion";
description = "Sets the Copyparty account name for password authentication.";
};
passwordFile = lib.mkOption {
type = lib.types.str;
description = "Sets the runtime file that contains the Copyparty account password.";
};
stateDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/copyparty";
description = "Sets the directory where Copyparty stores service state.";
};
volumes = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule {
@@ -115,30 +93,28 @@ in
services.copyparty = {
enable = true;
inherit (cfg)
group
stateDir
user
;
group = serviceGroup;
package = pkgs.copyparty-min;
stateDir = serviceStateDir;
user = serviceUser;
settings = {
i = "0.0.0.0";
p = cfg.port;
p = port;
usernames = true;
"http-only" = true;
"no-crt" = true;
"no-thumb" = true;
"no-snap" = true;
"no-rescan" = true;
"ses-db" = "${cfg.stateDir}/sessions.db";
"chpw-db" = "${cfg.stateDir}/chpw.json";
"shr-db" = "${cfg.stateDir}/shares.db";
"ses-db" = "${serviceStateDir}/sessions.db";
"chpw-db" = "${serviceStateDir}/chpw.json";
"shr-db" = "${serviceStateDir}/shares.db";
}
// lib.optionalAttrs cfg.reverseProxy.enable {
rproxy = 1;
"xff-hdr" = "x-forwarded-for";
};
accounts.${cfg.accountName}.passwordFile = cfg.passwordFile;
accounts.${config.user.name}.passwordFile = cfg.passwordFile;
globalExtraConfig = lib.optionalString cfg.reverseProxy.enable (
lib.concatMapStringsSep "\n" (source: "xff-src: ${source}") cfg.reverseProxy.trustedSources
);
@@ -152,9 +128,10 @@ in
}) cfg.volumes;
};
users.users.${cfg.user}.uid = config.registry."stable-uid".${config.networking.hostName}.copyparty;
users.users.${serviceUser}.uid =
config.registry."stable-uid".${config.networking.hostName}.copyparty;
networking.firewall.allowedTCPPorts = [ cfg.port ];
networking.firewall.allowedTCPPorts = [ port ];
})
];
}