From 161103ad7c8315c36590d6b0a4c32b9230c5fa1d Mon Sep 17 00:00:00 2001 From: alexion Date: Tue, 13 Oct 2026 09:37:59 -0400 Subject: [PATCH] refactor(copyparty): default writable volume settings --- configs/nixos/guests/copyparty.nix | 75 ++++++++++++++----------- configs/nixos/hosts/pikachu/default.nix | 12 ---- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/configs/nixos/guests/copyparty.nix b/configs/nixos/guests/copyparty.nix index 617741e..69305a5 100644 --- a/configs/nixos/guests/copyparty.nix +++ b/configs/nixos/guests/copyparty.nix @@ -5,40 +5,51 @@ }: let cfg = config.guests.copyparty; # NOLINT(let_order) + accountName = config.user.name; + volumeType = lib.types.submodule ( + { config, ... }: + { + options = { + hostPath = lib.mkOption { + type = lib.types.str; + description = "Host path bind-mounted into the Copyparty guest for this volume."; + }; + + path = lib.mkOption { + type = lib.types.str; + description = "Guest path served by this Copyparty volume."; + }; + + access = lib.mkOption { + type = lib.types.attrsOf (lib.types.listOf lib.types.str); + default.A = [ accountName ]; + description = "Copyparty access map from permission string to account names."; + }; + + readOnly = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Serve this Copyparty volume read-only."; + }; + + flags = lib.mkOption { + type = lib.types.attrs; + default = + if config.readOnly then + { } + else + { + d2d = true; + d2t = true; + dthumb = true; + }; + description = "Copyparty volume flags."; + }; + }; + } + ); stateDir = "/var/lib/copyparty"; - - volumeType = lib.types.submodule { - options = { - hostPath = lib.mkOption { - type = lib.types.str; - description = "Host path bind-mounted into the Copyparty guest for this volume."; - }; - - path = lib.mkOption { - type = lib.types.str; - description = "Guest path served by this Copyparty volume."; - }; - - access = lib.mkOption { - type = lib.types.attrsOf (lib.types.listOf lib.types.str); - default = { }; - description = "Copyparty access map from permission string to account names."; - }; - - readOnly = lib.mkOption { - type = lib.types.bool; - default = false; - description = "Serve this Copyparty volume read-only."; - }; - - flags = lib.mkOption { - type = lib.types.attrs; - default = { }; - description = "Copyparty volume flags."; - }; - }; - }; in { options.guests.copyparty = { diff --git a/configs/nixos/hosts/pikachu/default.nix b/configs/nixos/hosts/pikachu/default.nix index d25defa..866f7f8 100644 --- a/configs/nixos/hosts/pikachu/default.nix +++ b/configs/nixos/hosts/pikachu/default.nix @@ -135,22 +135,10 @@ "/inbox" = { hostPath = "/pikachu/__inbox"; path = "/pikachu/__inbox"; - access.A = [ config.user.name ]; - flags = { - d2d = true; - d2t = true; - dthumb = true; - }; }; "/media" = { hostPath = "/pikachu/media"; path = "/pikachu/media"; - access.A = [ config.user.name ]; - flags = { - d2d = true; - d2t = true; - dthumb = true; - }; }; "/opds" = { hostPath = "/pikachu/data/opds";