From 7a1086ef3bd8d431ea063925f6dd33b9a90d7d51 Mon Sep 17 00:00:00 2001 From: alexion Date: Mon, 12 Oct 2026 22:41:32 -0400 Subject: [PATCH] refactor(copyparty): remove unused wrapper options --- configs/nixos/guests/copyparty.nix | 21 ++----- configs/nixos/hosts/pikachu/default.nix | 8 +-- .../modules/services/copyparty/default.nix | 61 ++++++------------- 3 files changed, 28 insertions(+), 62 deletions(-) diff --git a/configs/nixos/guests/copyparty.nix b/configs/nixos/guests/copyparty.nix index fa985b5..617741e 100644 --- a/configs/nixos/guests/copyparty.nix +++ b/configs/nixos/guests/copyparty.nix @@ -6,6 +6,8 @@ let cfg = config.guests.copyparty; # NOLINT(let_order) + stateDir = "/var/lib/copyparty"; + volumeType = lib.types.submodule { options = { hostPath = lib.mkOption { @@ -40,22 +42,10 @@ let in { options.guests.copyparty = { - accountName = lib.mkOption { - type = lib.types.str; - default = "alexion"; - description = "Copyparty account name configured for password authentication."; - }; - passwordSecret = lib.mkOption { type = lib.types.str; - default = "services/copyparty/users/alexion/password"; - description = "SOPS secret name containing the Copyparty account password."; - }; - - stateDir = lib.mkOption { - type = lib.types.str; - default = "/var/lib/copyparty"; - description = "Guest path where Copyparty stores service state."; + default = "services/copyparty/users/${config.user.name}/password"; + description = "SOPS secret name that contains the Copyparty account password."; }; statePath = lib.mkOption { @@ -102,7 +92,6 @@ in guests.copyparty = { interior.modules.services.copyparty = { enable = true; - inherit (cfg) accountName stateDir; passwordFile = "/run/secrets/${cfg.passwordSecret}"; reverseProxy = { enable = cfg.reverseProxy.enable; @@ -119,7 +108,7 @@ in }; mounts = { - ${cfg.stateDir} = { + ${stateDir} = { directory = cfg.statePath; owner = config.registry."stable-uid".${config.networking.hostName}.copyparty; group = "storage"; diff --git a/configs/nixos/hosts/pikachu/default.nix b/configs/nixos/hosts/pikachu/default.nix index 7f09388..d25defa 100644 --- a/configs/nixos/hosts/pikachu/default.nix +++ b/configs/nixos/hosts/pikachu/default.nix @@ -129,13 +129,13 @@ "/" = { hostPath = "/pikachu/data/copyparty/root"; path = "/srv"; - access.r = [ "alexion" ]; + access.r = [ config.user.name ]; readOnly = true; }; "/inbox" = { hostPath = "/pikachu/__inbox"; path = "/pikachu/__inbox"; - access.A = [ "alexion" ]; + access.A = [ config.user.name ]; flags = { d2d = true; d2t = true; @@ -145,7 +145,7 @@ "/media" = { hostPath = "/pikachu/media"; path = "/pikachu/media"; - access.A = [ "alexion" ]; + access.A = [ config.user.name ]; flags = { d2d = true; d2t = true; @@ -155,7 +155,7 @@ "/opds" = { hostPath = "/pikachu/data/opds"; path = "/pikachu/data/opds"; - access.r = [ "alexion" ]; + access.r = [ config.user.name ]; readOnly = true; flags.opds = true; }; diff --git a/configs/nixos/modules/services/copyparty/default.nix b/configs/nixos/modules/services/copyparty/default.nix index 828dbe2..dca3c00 100644 --- a/configs/nixos/modules/services/copyparty/default.nix +++ b/configs/nixos/modules/services/copyparty/default.nix @@ -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 ]; }) ]; }