fix(nixos) : escape paths with spaces for systemd BindPaths

This commit is contained in:
Shayan Zara 2026-05-03 04:26:23 +05:00
parent 6e25d648a9
commit ee97dc64e4

View file

@ -1,4 +1,4 @@
{ v{
config, config,
pkgs, pkgs,
lib, lib,
@ -29,6 +29,7 @@ let
(generators.mkValueStringDefault { } value); (generators.mkValueStringDefault { } value);
mkSectionName = value: "[" + (escape [ "[" "]" ] value) + "]"; mkSectionName = value: "[" + (escape [ "[" "]" ] value) + "]";
mkSection = name: attrs: '' mkSection = name: attrs: ''
${mkSectionName name} ${mkSectionName name}
@ -57,6 +58,7 @@ let
${mkSection "groups" cfg.groups} ${mkSection "groups" cfg.groups}
${concatStringsSep "\n" (mapAttrsToList mkVolume cfg.volumes)} ${concatStringsSep "\n" (mapAttrsToList mkVolume cfg.volumes)}
''; '';
escapePath = p: lib.replaceStrings [" "]["\\x20"] (toString p);
cfg = config.services.copyparty; cfg = config.services.copyparty;
configFile = pkgs.writeText "copyparty.conf" configStr; configFile = pkgs.writeText "copyparty.conf" configStr;
@ -323,8 +325,8 @@ in
] ++ (mapAttrsToList (k: v: "-${v.passwordFile}") cfg.accounts); ] ++ (mapAttrsToList (k: v: "-${v.passwordFile}") cfg.accounts);
BindPaths = BindPaths =
(if cfg.settings ? hist then [ cfg.settings.hist ] else [ ]) (if cfg.settings ? hist then [ cfg.settings.hist ] else [ ])
++ [ externalStateDir ] ++ [ (escapePath externalStateDir) ]
++ (mapAttrsToList (k: v: v.path) volumesWithoutVariables); ++ (mapAttrsToList (k: v: escapePath v.path) volumesWithoutVariables);
# ProtectSystem = "strict"; # ProtectSystem = "strict";
# Note that unlike what 'ro' implies, # Note that unlike what 'ro' implies,
# this actually makes it impossible to read anything in the root FS, # this actually makes it impossible to read anything in the root FS,