removed seperatehist in favor of default settings attrset.

This commit is contained in:
Gabe Venberg 2025-04-25 12:27:40 +02:00
parent 7c9cc76847
commit cf9f2518a8

View file

@ -105,16 +105,6 @@ in {
description = "Number of files to allow copyparty to open."; description = "Number of files to allow copyparty to open.";
}; };
separateHist = mkOption {
default = true;
type = types.bool;
description = ''
Whether to have cache directories separate from their associated volumes.
Disabling this can be useful if you want the served volume to be portable between machines, or otherwise self-contained.
'';
};
settings = mkOption { settings = mkOption {
type = types.attrs; type = types.attrs;
description = '' description = ''
@ -126,11 +116,13 @@ in {
default = { default = {
i = "127.0.0.1"; i = "127.0.0.1";
no-reload = true; no-reload = true;
hist = externalCacheDir;
}; };
example = literalExpression '' example = literalExpression ''
{ {
i = "0.0.0.0"; i = "0.0.0.0";
no-reload = true; no-reload = true;
hist = ${externalCacheDir};
} }
''; '';
}; };
@ -270,8 +262,7 @@ in {
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
ExecStart = '' ExecStart = ''
${getExe cfg.package} -c ${runtimeConfigPath} \ ${getExe cfg.package} -c ${runtimeConfigPath}
${optionalString (cfg.separateHist) "--hist ${externalCacheDir}"}
''; '';
# Hardening options # Hardening options
@ -281,8 +272,8 @@ in {
RuntimeDirectoryMode = "0700"; RuntimeDirectoryMode = "0700";
StateDirectory = ["copyparty"]; StateDirectory = ["copyparty"];
StateDirectoryMode = "0700"; StateDirectoryMode = "0700";
CacheDirectory = lib.mkIf cfg.separateHist ["copyparty"]; CacheDirectory = lib.mkIf (cfg.settings ? hist) ["copyparty"];
CacheDirectoryMode = lib.mkIf cfg.separateHist "0700"; CacheDirectoryMode = lib.mkIf (cfg.settings ? hist) "0700";
WorkingDirectory = externalStateDir; WorkingDirectory = externalStateDir;
BindReadOnlyPaths = BindReadOnlyPaths =
[ [
@ -295,8 +286,8 @@ in {
++ (mapAttrsToList (k: v: "-${v.passwordFile}") cfg.accounts); ++ (mapAttrsToList (k: v: "-${v.passwordFile}") cfg.accounts);
BindPaths = BindPaths =
( (
if cfg.separateHist if cfg.settings ? hist
then [externalCacheDir] then [cfg.hist]
else [] else []
) )
++ [externalStateDir] ++ [externalStateDir]
@ -348,7 +339,7 @@ in {
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";
group = "copyparty"; group = "copyparty";
home = lib.mkIf cfg.separateHist externalStateDir; home = externalStateDir;
isSystemUser = true; isSystemUser = true;
}; };
environment.systemPackages = lib.mkIf cfg.mkHashWrapper [ environment.systemPackages = lib.mkIf cfg.mkHashWrapper [
@ -356,7 +347,6 @@ in {
let let
command = '' command = ''
${getExe cfg.package} -c ${runtimeConfigPath} \ ${getExe cfg.package} -c ${runtimeConfigPath} \
${optionalString (cfg.separateHist) "--hist ${externalCacheDir}"} \
--shr-db ''' \ --shr-db ''' \
--ses-db ''' \ --ses-db ''' \
--ah-cli \ --ah-cli \