refactor(copyparty): separate deployment and service policy

Move Copyparty rendering into shared dotfiles utilities, keep guest wiring focused on host/container plumbing, and let the service module derive effective volume policy.
This commit was merged in pull request #182.
This commit is contained in:
2026-10-13 20:33:25 -04:00
parent d0872e7d8c
commit 8462b3a5a8
6 changed files with 226 additions and 200 deletions

View File

@@ -14,7 +14,7 @@ let
registry = registry.collected;
};
util = import ./util.nix { inherit lib; };
util = import ./util { inherit lib; };
registry = import ./registry.nix {
inherit lib util;

View File

@@ -21,8 +21,9 @@ let
value: entries: builtins.length (lib.unique (map value entries)) == builtins.length entries;
in
{
inherit collectNixFiles;
formats.copyparty = import ./format-copyparty.nix { inherit lib; };
inherit collectNixFiles;
removeNixSuffix = path: lib.removeSuffix ".nix" (builtins.baseNameOf path);
glyph =

View File

@@ -0,0 +1,58 @@
{ lib }:
let
renderLine =
indent: name: value:
if value == true then
"${indent}${name}"
else if value == false then
null
else if lib.isList value then
"${indent}${name}: ${lib.concatStringsSep ", " (map toString value)}"
else
"${indent}${name}: ${toString value}";
renderAttrs =
indent: attrs:
lib.pipe attrs [
lib.attrsToList
(map ({ name, value }: renderLine indent name value))
(lib.filter (line: line != null))
(lib.concatStringsSep "\n")
];
renderSectionName = name: "[${lib.escape [ "[" "]" ] name}]";
renderSection = name: attrs: ''
${renderSectionName name}
${renderAttrs "" attrs}
'';
renderSubsection =
name: attrs:
lib.optionalString (attrs != { }) ''
${name}:
${renderAttrs " " attrs}
'';
renderVolume = urlPath: volume: ''
${renderSectionName urlPath}
${volume.path}
${renderSubsection "accs" volume.access}
${renderSubsection "flags" volume.flags}
'';
in
{
render =
{
accounts,
global,
volumes,
globalExtraConfig ? "",
}:
''
${renderSection "global" global}
${globalExtraConfig}
${renderSection "accounts" accounts}
${lib.concatStringsSep "\n" (lib.mapAttrsToList renderVolume volumes)}
'';
}