From 8517a172421576f93bf43c896f050910a9f7a365 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:05:14 -0600 Subject: test complicated copyparty config --- modules/services/nixos/copyparty.nix | 81 ++++++++++++++++++------------------ modules/services/options.nix | 29 +++++++++++-- 2 files changed, 66 insertions(+), 44 deletions(-) (limited to 'modules') diff --git a/modules/services/nixos/copyparty.nix b/modules/services/nixos/copyparty.nix index 68701a1..ec882d9 100644 --- a/modules/services/nixos/copyparty.nix +++ b/modules/services/nixos/copyparty.nix @@ -12,11 +12,16 @@ in { ]; config = lib.mkIf cfg.enable { + users.groups."fileserver".members = [config.collinux.user.name]; + services.copyparty = { enable = true; + user = "copyparty"; + group = "fileserver"; + settings = { - i = "0.0.0.0"; + i = cfg.bind_host; p = [cfg.port]; chpw = true; rproxy = "1"; @@ -27,47 +32,43 @@ in { e2ts = true; }; - accounts = { - collin = { - passwordFile = config.collinux.secrets."collin-copyparty-password".path; - }; - }; - - groups.admin = ["collin"]; + accounts = + cfg.users + |> map (x: { + inherit (x) passwordFile; + }); - volumes = let - commonFlags = { - scan = 60; - chmod_f = "777"; - chmod_d = "777"; - }; - in { - "/" = { - path = "/media/public"; - access = { - r = "*"; - A = ["@admin"]; - }; + groups.admin = cfg.users |> lib.attrs.filterAttrs (k: v: v.isAdmin == true) |> builtins.attrNames; - flags = commonFlags; - }; - - "/collin" = { - path = "/media/collin"; - access.A = ["collin"]; - - flags = commonFlags; - }; - "/public/collin" = { - path = "/media/collin/public"; - access = { - r = "*"; - A = ["collin"]; - }; - - flags = commonFlags; - }; - }; + volumes = lib.mkMerge ([ + { + "/" = { + path = "/media/public"; + access = { + r = "*"; + A = ["@admin"]; + }; + }; + } + ] + ++ lib.lists.flatten (cfg.users + |> map (x: [ + { + "/${x.name}" = { + path = "/media/${x.name}"; + access.A = [x.name]; + }; + } + (lib.optionalAttrs x.hasPublicDir { + "/public/${x.name}" = { + path = "/media/${x.name}/public"; + access = { + r = "*"; + A = [x.name]; + }; + }; + }) + ]))); }; }; } diff --git a/modules/services/options.nix b/modules/services/options.nix index 19812fc..024e2a0 100644 --- a/modules/services/options.nix +++ b/modules/services/options.nix @@ -77,10 +77,31 @@ in { }; }; - copyparty = selfhostOptions { - service_name = "copyparty"; - default_port = 8099; - }; + copyparty = + (selfhostOptions { + service_name = "copyparty"; + default_port = 8099; + }) + // { + users = mkOption { + type = lib.types.attrsOf (lib.types.submodule ({config, ...}: { + options = { + name = mkOption { + type = lib.types.str; + default = config._module.args.name; + internal = true; + }; + isAdmin = mkEnableOption "whether this user is an admin"; + passwordFile = mkOption { + description = "Absolute path to a file containing the password for this user"; + type = lib.types.str; + example = "/run/secrets.d/copyparty-passwd"; + }; + hasPublicDir = mkEnableOption "give this user a world-readable directory at /public/"; + }; + })); + }; + }; ngircd = { enable = mkEnableOption "IRC Server"; -- cgit v1.3.1