Merge pull request 'fix: pi settings sync' (#7) from fix/pi-sync-settings into master
Some checks failed
Update Nix Packages with nix-update / nix-update (push) Failing after 7m1s

Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
2026-04-14 20:16:38 +02:00

View File

@@ -42,7 +42,11 @@ with lib; let
mapAttrsToList ( mapAttrsToList (
user: userCfg: '' user: userCfg: ''
${escapeShellArg user}) ${escapeShellArg user})
USER_CONFIG_PATH=${escapeShellArg (if userCfg.configPath != null then userCfg.configPath else cfg.wrapper.hostConfigPath)} USER_CONFIG_PATH=${escapeShellArg (
if userCfg.configPath != null
then userCfg.configPath
else cfg.wrapper.hostConfigPath
)}
USER_ROOTS=(${concatStringsSep " " (map escapeShellArg userCfg.projectRoots)}) USER_ROOTS=(${concatStringsSep " " (map escapeShellArg userCfg.projectRoots)})
;; ;;
'' ''
@@ -98,8 +102,11 @@ with lib; let
printf '%s\n' "$user_home" printf '%s\n' "$user_home"
elif ${pkgs.gnugrep}/bin/grep -q '^~/' <<<"$input"; then elif ${pkgs.gnugrep}/bin/grep -q '^~/' <<<"$input"; then
printf '%s\n' "$user_home/''${input:2}" printf '%s\n' "$user_home/''${input:2}"
else elif ${pkgs.gnugrep}/bin/grep -q '^/' <<<"$input"; then
printf '%s\n' "$input" printf '%s\n' "$input"
else
# Bare relative path resolve from user's home
printf '%s\n' "$user_home/$input"
fi fi
} }
@@ -162,7 +169,11 @@ with lib; let
fi fi
if [ "${if cfg.wrapper.syncConfigFromHost then "1" else "0"}" = "1" ] && [ -d "$source_dir" ]; then if [ "${
if cfg.wrapper.syncConfigFromHost
then "1"
else "0"
}" = "1" ] && [ -d "$source_dir" ]; then
${pkgs.rsync}/bin/rsync -a --delete "$source_dir/" ${escapeShellArg "${cfg.stateDir}/.pi/agent/"} ${pkgs.rsync}/bin/rsync -a --delete "$source_dir/" ${escapeShellArg "${cfg.stateDir}/.pi/agent/"}
${pkgs.coreutils}/bin/chown -R ${escapeShellArg "${cfg.user}:${cfg.group}"} ${escapeShellArg "${cfg.stateDir}/.pi/agent"} ${pkgs.coreutils}/bin/chown -R ${escapeShellArg "${cfg.user}:${cfg.group}"} ${escapeShellArg "${cfg.stateDir}/.pi/agent"}
fi fi
@@ -239,7 +250,8 @@ PY_PI_SETTINGS_MERGE
${pkgs.coreutils}/bin/cat ${escapeShellArg f} >> "$env_target" ${pkgs.coreutils}/bin/cat ${escapeShellArg f} >> "$env_target"
printf '\n' >> "$env_target" printf '\n' >> "$env_target"
fi fi
'') cfg.environmentFiles)} '')
cfg.environmentFiles)}
${pkgs.coreutils}/bin/chown ${escapeShellArg "${cfg.user}:${cfg.group}"} "$env_target" ${pkgs.coreutils}/bin/chown ${escapeShellArg "${cfg.user}:${cfg.group}"} "$env_target"
${pkgs.coreutils}/bin/chmod 0640 "$env_target" ${pkgs.coreutils}/bin/chmod 0640 "$env_target"
@@ -410,8 +422,10 @@ PY_PI_SETTINGS_MERGE
printf '%s\n' "$user_home" printf '%s\n' "$user_home"
elif ${pkgs.gnugrep}/bin/grep -q '^~/' <<<"$input"; then elif ${pkgs.gnugrep}/bin/grep -q '^~/' <<<"$input"; then
printf '%s\n' "$user_home/''${input:2}" printf '%s\n' "$user_home/''${input:2}"
else elif ${pkgs.gnugrep}/bin/grep -q '^/' <<<"$input"; then
printf '%s\n' "$input" printf '%s\n' "$input"
else
printf '%s\n' "$user_home/$input"
fi fi
} }
@@ -657,7 +671,8 @@ in {
++ mapAttrsToList (user: userCfg: { ++ mapAttrsToList (user: userCfg: {
assertion = userCfg.projectRoots != []; assertion = userCfg.projectRoots != [];
message = "m3ta.pi-agent.hostUsers.${user}.projectRoots must not be empty."; message = "m3ta.pi-agent.hostUsers.${user}.projectRoots must not be empty.";
}) cfg.hostUsers; })
cfg.hostUsers;
users.groups = mkIf cfg.createUser { users.groups = mkIf cfg.createUser {
"${cfg.group}" = {}; "${cfg.group}" = {};