aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-02-06 14:05:14 -0600
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-02-06 14:06:18 -0600
commit8517a172421576f93bf43c896f050910a9f7a365 (patch)
tree83d4675e4354554fe03db4584d51706a92ab6d31 /modules
parentf2eabd23ef1817adc872cc23685e4c5c49876ba7 (diff)
test complicated copyparty config
Diffstat (limited to 'modules')
-rw-r--r--modules/services/nixos/copyparty.nix81
-rw-r--r--modules/services/options.nix29
2 files changed, 66 insertions, 44 deletions
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/<username>";
+ };
+ }));
+ };
+ };
ngircd = {
enable = mkEnableOption "IRC Server";