From ee97dc64e43617fd04455e570d9b50063c08b48d Mon Sep 17 00:00:00 2001 From: Shayan Zara Date: Sun, 3 May 2026 04:26:23 +0500 Subject: [PATCH] fix(nixos) : escape paths with spaces for systemd BindPaths --- contrib/nixos/modules/copyparty.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/nixos/modules/copyparty.nix b/contrib/nixos/modules/copyparty.nix index 13a8c21c..482bf5c0 100644 --- a/contrib/nixos/modules/copyparty.nix +++ b/contrib/nixos/modules/copyparty.nix @@ -1,4 +1,4 @@ -{ +v{ config, pkgs, lib, @@ -29,6 +29,7 @@ let (generators.mkValueStringDefault { } value); mkSectionName = value: "[" + (escape [ "[" "]" ] value) + "]"; + mkSection = name: attrs: '' ${mkSectionName name} @@ -57,6 +58,7 @@ let ${mkSection "groups" cfg.groups} ${concatStringsSep "\n" (mapAttrsToList mkVolume cfg.volumes)} ''; + escapePath = p: lib.replaceStrings [" "]["\\x20"] (toString p); cfg = config.services.copyparty; configFile = pkgs.writeText "copyparty.conf" configStr; @@ -323,8 +325,8 @@ in ] ++ (mapAttrsToList (k: v: "-${v.passwordFile}") cfg.accounts); BindPaths = (if cfg.settings ? hist then [ cfg.settings.hist ] else [ ]) - ++ [ externalStateDir ] - ++ (mapAttrsToList (k: v: v.path) volumesWithoutVariables); + ++ [ (escapePath externalStateDir) ] + ++ (mapAttrsToList (k: v: escapePath v.path) volumesWithoutVariables); # ProtectSystem = "strict"; # Note that unlike what 'ro' implies, # this actually makes it impossible to read anything in the root FS,