diff --git a/configs/nixos/guests/copyparty.nix b/configs/nixos/guests/copyparty.nix index fd4d9b7..fa985b5 100644 --- a/configs/nixos/guests/copyparty.nix +++ b/configs/nixos/guests/copyparty.nix @@ -31,8 +31,8 @@ let }; flags = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = [ ]; + type = lib.types.attrs; + default = { }; description = "Copyparty volume flags."; }; }; diff --git a/configs/nixos/hosts/pikachu/default.nix b/configs/nixos/hosts/pikachu/default.nix index 62c0be8..7f09388 100644 --- a/configs/nixos/hosts/pikachu/default.nix +++ b/configs/nixos/hosts/pikachu/default.nix @@ -136,28 +136,28 @@ hostPath = "/pikachu/__inbox"; path = "/pikachu/__inbox"; access.A = [ "alexion" ]; - flags = [ - "d2d" - "d2t" - "dthumb" - ]; + flags = { + d2d = true; + d2t = true; + dthumb = true; + }; }; "/media" = { hostPath = "/pikachu/media"; path = "/pikachu/media"; access.A = [ "alexion" ]; - flags = [ - "d2d" - "d2t" - "dthumb" - ]; + flags = { + d2d = true; + d2t = true; + dthumb = true; + }; }; "/opds" = { hostPath = "/pikachu/data/opds"; path = "/pikachu/data/opds"; access.r = [ "alexion" ]; readOnly = true; - flags = [ "opds" ]; + flags.opds = true; }; }; }; diff --git a/configs/nixos/lib/copyparty-config.nix b/configs/nixos/lib/copyparty-config.nix deleted file mode 100644 index 4c3a52a..0000000 --- a/configs/nixos/lib/copyparty-config.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ - lib, - pkgs, -}: -cfg: -let - renderedReverseProxy = lib.optionalString cfg.reverseProxy.enable '' - rproxy: 1 - xff-hdr: x-forwarded-for - ${lib.concatStringsSep "\n" (map renderTrustedSource cfg.reverseProxy.trustedSources)} - ''; - - renderTrustedSource = source: " xff-src: ${source}"; - - renderedVolumes = lib.concatStringsSep "\n" (lib.mapAttrsToList renderVolume cfg.volumes); - - renderVolume = urlPath: volume: '' - [${urlPath}] - ${volume.path} - accs: - ${lib.concatStringsSep "\n" (lib.mapAttrsToList renderAccess volume.access)} - ${lib.optionalString (volume.flags != [ ]) '' - flags: - ${renderFlags volume.flags} - ''} - ''; - - renderAccess = permission: accounts: " ${permission}: ${lib.concatStringsSep ", " accounts}"; - - renderFlags = - flags: lib.concatMapStringsSep "\n" (flag: " ${flag}") (flags ++ defaultPermissionFlags flags); - - defaultPermissionFlags = - flags: - lib.optionals (!(hasFlag "chmod_d" flags)) [ "chmod_d: 2770" ] - ++ lib.optionals (!(hasFlag "chmod_f" flags)) [ "chmod_f: 660" ]; - - hasFlag = - name: flags: lib.any (flag: lib.hasPrefix "${name}:" flag || lib.hasPrefix "${name}=" flag) flags; -in -pkgs.writeShellScript "copyparty-config" '' - set -eu - - umask 077 - password="$(${lib.getExe' pkgs.coreutils "tr"} -d '\n' < "$CREDENTIALS_DIRECTORY/password")" - - cat > /run/copyparty/copyparty.conf <