mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
added option to have hist data live with volumes.
This commit is contained in:
parent
5520fe611b
commit
d94f3a5e66
|
@ -54,8 +54,8 @@ with lib; let
|
||||||
cfg = config.services.copyparty;
|
cfg = config.services.copyparty;
|
||||||
configFile = pkgs.writeText "copyparty.conf" configStr;
|
configFile = pkgs.writeText "copyparty.conf" configStr;
|
||||||
runtimeConfigPath = "/run/copyparty/copyparty.conf";
|
runtimeConfigPath = "/run/copyparty/copyparty.conf";
|
||||||
stateDir = "/var/lib/copyparty";
|
externalStateDir = "/var/lib/copyparty";
|
||||||
defaultShareDir = "${stateDir}/data";
|
defaultShareDir = "${externalStateDir}/data";
|
||||||
in {
|
in {
|
||||||
options.services.copyparty = {
|
options.services.copyparty = {
|
||||||
enable = mkEnableOption "web-based file manager";
|
enable = mkEnableOption "web-based file manager";
|
||||||
|
@ -95,6 +95,16 @@ in {
|
||||||
description = "Number of files to allow copyparty to open.";
|
description = "Number of files to allow copyparty to open.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
seperateHist = mkOption {
|
||||||
|
default = true;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to have cache directories seperate 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 = ''
|
||||||
|
@ -233,7 +243,7 @@ in {
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
PYTHONUNBUFFERED = "true";
|
PYTHONUNBUFFERED = "true";
|
||||||
XDG_CONFIG_HOME = "home";
|
XDG_CONFIG_HOME = lib.mkIf cfg.seperateHist externalStateDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
preStart = let
|
preStart = let
|
||||||
|
@ -249,16 +259,19 @@ in {
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart = "${getExe cfg.package} -c ${runtimeConfigPath} --hist ${stateDir}";
|
ExecStart = ''
|
||||||
|
${getExe cfg.package} -c ${runtimeConfigPath} \
|
||||||
|
${optionalString (cfg.seperateHist) "--hist ${externalStateDir}"}
|
||||||
|
'';
|
||||||
|
|
||||||
# Hardening options
|
# Hardening options
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
RuntimeDirectory = ["copyparty"];
|
RuntimeDirectory = ["copyparty"];
|
||||||
RuntimeDirectoryMode = "0700";
|
RuntimeDirectoryMode = "0700";
|
||||||
StateDirectory = ["copyparty"];
|
StateDirectory = lib.mkIf cfg.seperateHist ["copyparty"];
|
||||||
StateDirectoryMode = "0700";
|
StateDirectoryMode = lib.mkIf cfg.seperateHist "0700";
|
||||||
WorkingDirectory = stateDir;
|
WorkingDirectory = lib.mkIf cfg.seperateHist externalStateDir;
|
||||||
BindReadOnlyPaths =
|
BindReadOnlyPaths =
|
||||||
[
|
[
|
||||||
"/nix/store"
|
"/nix/store"
|
||||||
|
@ -268,7 +281,13 @@ in {
|
||||||
"-/etc/localtime"
|
"-/etc/localtime"
|
||||||
]
|
]
|
||||||
++ (mapAttrsToList (k: v: "-${v.passwordFile}") cfg.accounts);
|
++ (mapAttrsToList (k: v: "-${v.passwordFile}") cfg.accounts);
|
||||||
BindPaths = [stateDir] ++ (mapAttrsToList (k: v: v.path) cfg.volumes);
|
BindPaths =
|
||||||
|
(
|
||||||
|
if cfg.seperateHist
|
||||||
|
then [externalStateDir]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (mapAttrsToList (k: v: v.path) cfg.volumes);
|
||||||
ProtectSystem = "strict";
|
ProtectSystem = "strict";
|
||||||
ProtectHome = "tmpfs";
|
ProtectHome = "tmpfs";
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
|
@ -291,7 +310,6 @@ in {
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
MemoryDenyWriteExecute = true;
|
MemoryDenyWriteExecute = true;
|
||||||
# RestrictAddressFamilies = "none";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -299,7 +317,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 = stateDir;
|
home = lib.mkIf cfg.seperateHist externalStateDir;
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue