refactor(copyparty): remove unused wrapper options
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
let
|
let
|
||||||
cfg = config.guests.copyparty; # NOLINT(let_order)
|
cfg = config.guests.copyparty; # NOLINT(let_order)
|
||||||
|
|
||||||
|
stateDir = "/var/lib/copyparty";
|
||||||
|
|
||||||
volumeType = lib.types.submodule {
|
volumeType = lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
hostPath = lib.mkOption {
|
hostPath = lib.mkOption {
|
||||||
@@ -40,22 +42,10 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.guests.copyparty = {
|
options.guests.copyparty = {
|
||||||
accountName = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "alexion";
|
|
||||||
description = "Copyparty account name configured for password authentication.";
|
|
||||||
};
|
|
||||||
|
|
||||||
passwordSecret = lib.mkOption {
|
passwordSecret = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "services/copyparty/users/alexion/password";
|
default = "services/copyparty/users/${config.user.name}/password";
|
||||||
description = "SOPS secret name containing the Copyparty account password.";
|
description = "SOPS secret name that contains the Copyparty account password.";
|
||||||
};
|
|
||||||
|
|
||||||
stateDir = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "/var/lib/copyparty";
|
|
||||||
description = "Guest path where Copyparty stores service state.";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
statePath = lib.mkOption {
|
statePath = lib.mkOption {
|
||||||
@@ -102,7 +92,6 @@ in
|
|||||||
guests.copyparty = {
|
guests.copyparty = {
|
||||||
interior.modules.services.copyparty = {
|
interior.modules.services.copyparty = {
|
||||||
enable = true;
|
enable = true;
|
||||||
inherit (cfg) accountName stateDir;
|
|
||||||
passwordFile = "/run/secrets/${cfg.passwordSecret}";
|
passwordFile = "/run/secrets/${cfg.passwordSecret}";
|
||||||
reverseProxy = {
|
reverseProxy = {
|
||||||
enable = cfg.reverseProxy.enable;
|
enable = cfg.reverseProxy.enable;
|
||||||
@@ -119,7 +108,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
mounts = {
|
mounts = {
|
||||||
${cfg.stateDir} = {
|
${stateDir} = {
|
||||||
directory = cfg.statePath;
|
directory = cfg.statePath;
|
||||||
owner = config.registry."stable-uid".${config.networking.hostName}.copyparty;
|
owner = config.registry."stable-uid".${config.networking.hostName}.copyparty;
|
||||||
group = "storage";
|
group = "storage";
|
||||||
|
|||||||
@@ -129,13 +129,13 @@
|
|||||||
"/" = {
|
"/" = {
|
||||||
hostPath = "/pikachu/data/copyparty/root";
|
hostPath = "/pikachu/data/copyparty/root";
|
||||||
path = "/srv";
|
path = "/srv";
|
||||||
access.r = [ "alexion" ];
|
access.r = [ config.user.name ];
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
};
|
};
|
||||||
"/inbox" = {
|
"/inbox" = {
|
||||||
hostPath = "/pikachu/__inbox";
|
hostPath = "/pikachu/__inbox";
|
||||||
path = "/pikachu/__inbox";
|
path = "/pikachu/__inbox";
|
||||||
access.A = [ "alexion" ];
|
access.A = [ config.user.name ];
|
||||||
flags = {
|
flags = {
|
||||||
d2d = true;
|
d2d = true;
|
||||||
d2t = true;
|
d2t = true;
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
"/media" = {
|
"/media" = {
|
||||||
hostPath = "/pikachu/media";
|
hostPath = "/pikachu/media";
|
||||||
path = "/pikachu/media";
|
path = "/pikachu/media";
|
||||||
access.A = [ "alexion" ];
|
access.A = [ config.user.name ];
|
||||||
flags = {
|
flags = {
|
||||||
d2d = true;
|
d2d = true;
|
||||||
d2t = true;
|
d2t = true;
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
"/opds" = {
|
"/opds" = {
|
||||||
hostPath = "/pikachu/data/opds";
|
hostPath = "/pikachu/data/opds";
|
||||||
path = "/pikachu/data/opds";
|
path = "/pikachu/data/opds";
|
||||||
access.r = [ "alexion" ];
|
access.r = [ config.user.name ];
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
flags.opds = true;
|
flags.opds = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,46 +6,24 @@
|
|||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.modules.services.copyparty; # NOLINT(let_order)
|
cfg = config.modules.services.copyparty; # NOLINT(let_order)
|
||||||
|
|
||||||
|
port = 3923;
|
||||||
|
|
||||||
|
serviceGroup = "storage";
|
||||||
|
|
||||||
|
serviceStateDir = "/var/lib/copyparty";
|
||||||
|
|
||||||
|
serviceUser = "copyparty";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.services.copyparty = {
|
options.modules.services.copyparty = {
|
||||||
enable = lib.mkEnableOption "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 {
|
passwordFile = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Sets the runtime file that contains the Copyparty account password.";
|
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 {
|
volumes = lib.mkOption {
|
||||||
type = lib.types.attrsOf (
|
type = lib.types.attrsOf (
|
||||||
lib.types.submodule {
|
lib.types.submodule {
|
||||||
@@ -115,30 +93,28 @@ in
|
|||||||
|
|
||||||
services.copyparty = {
|
services.copyparty = {
|
||||||
enable = true;
|
enable = true;
|
||||||
inherit (cfg)
|
group = serviceGroup;
|
||||||
group
|
|
||||||
stateDir
|
|
||||||
user
|
|
||||||
;
|
|
||||||
package = pkgs.copyparty-min;
|
package = pkgs.copyparty-min;
|
||||||
|
stateDir = serviceStateDir;
|
||||||
|
user = serviceUser;
|
||||||
settings = {
|
settings = {
|
||||||
i = "0.0.0.0";
|
i = "0.0.0.0";
|
||||||
p = cfg.port;
|
p = port;
|
||||||
usernames = true;
|
usernames = true;
|
||||||
"http-only" = true;
|
"http-only" = true;
|
||||||
"no-crt" = true;
|
"no-crt" = true;
|
||||||
"no-thumb" = true;
|
"no-thumb" = true;
|
||||||
"no-snap" = true;
|
"no-snap" = true;
|
||||||
"no-rescan" = true;
|
"no-rescan" = true;
|
||||||
"ses-db" = "${cfg.stateDir}/sessions.db";
|
"ses-db" = "${serviceStateDir}/sessions.db";
|
||||||
"chpw-db" = "${cfg.stateDir}/chpw.json";
|
"chpw-db" = "${serviceStateDir}/chpw.json";
|
||||||
"shr-db" = "${cfg.stateDir}/shares.db";
|
"shr-db" = "${serviceStateDir}/shares.db";
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs cfg.reverseProxy.enable {
|
// lib.optionalAttrs cfg.reverseProxy.enable {
|
||||||
rproxy = 1;
|
rproxy = 1;
|
||||||
"xff-hdr" = "x-forwarded-for";
|
"xff-hdr" = "x-forwarded-for";
|
||||||
};
|
};
|
||||||
accounts.${cfg.accountName}.passwordFile = cfg.passwordFile;
|
accounts.${config.user.name}.passwordFile = cfg.passwordFile;
|
||||||
globalExtraConfig = lib.optionalString cfg.reverseProxy.enable (
|
globalExtraConfig = lib.optionalString cfg.reverseProxy.enable (
|
||||||
lib.concatMapStringsSep "\n" (source: "xff-src: ${source}") cfg.reverseProxy.trustedSources
|
lib.concatMapStringsSep "\n" (source: "xff-src: ${source}") cfg.reverseProxy.trustedSources
|
||||||
);
|
);
|
||||||
@@ -152,9 +128,10 @@ in
|
|||||||
}) cfg.volumes;
|
}) 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 ];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user