chore/update-gitignore-and-changes #11
@@ -42,7 +42,11 @@ with lib; let
|
||||
mapAttrsToList (
|
||||
user: userCfg: ''
|
||||
${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)})
|
||||
;;
|
||||
''
|
||||
@@ -98,8 +102,11 @@ with lib; let
|
||||
printf '%s\n' "$user_home"
|
||||
elif ${pkgs.gnugrep}/bin/grep -q '^~/' <<<"$input"; then
|
||||
printf '%s\n' "$user_home/''${input:2}"
|
||||
else
|
||||
elif ${pkgs.gnugrep}/bin/grep -q '^/' <<<"$input"; then
|
||||
printf '%s\n' "$input"
|
||||
else
|
||||
# Bare relative path → resolve from user's home
|
||||
printf '%s\n' "$user_home/$input"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -162,7 +169,11 @@ with lib; let
|
||||
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.coreutils}/bin/chown -R ${escapeShellArg "${cfg.user}:${cfg.group}"} ${escapeShellArg "${cfg.stateDir}/.pi/agent"}
|
||||
fi
|
||||
@@ -171,12 +182,12 @@ with lib; let
|
||||
# Precedence: host settings first, Nix-managed keys override recursively.
|
||||
settings_target=${escapeShellArg "${cfg.stateDir}/.pi/agent/settings.json"}
|
||||
${pkgs.python3}/bin/python3 - "$settings_target" ${escapeShellArg managedSettingsFile} <<'PY_PI_SETTINGS_MERGE'
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def load_obj(path):
|
||||
def load_obj(path):
|
||||
if not os.path.exists(path):
|
||||
return {}
|
||||
try:
|
||||
@@ -187,7 +198,7 @@ def load_obj(path):
|
||||
return {}
|
||||
|
||||
|
||||
def deep_merge(base, override):
|
||||
def deep_merge(base, override):
|
||||
if isinstance(base, dict) and isinstance(override, dict):
|
||||
out = dict(base)
|
||||
for key, value in override.items():
|
||||
@@ -196,7 +207,7 @@ def deep_merge(base, override):
|
||||
return override
|
||||
|
||||
|
||||
def main():
|
||||
def main():
|
||||
target = sys.argv[1]
|
||||
managed = sys.argv[2]
|
||||
base_obj = load_obj(target)
|
||||
@@ -211,9 +222,9 @@ def main():
|
||||
os.replace(tmp, target)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
PY_PI_SETTINGS_MERGE
|
||||
PY_PI_SETTINGS_MERGE
|
||||
${pkgs.coreutils}/bin/chown ${escapeShellArg "${cfg.user}:${cfg.group}"} "$settings_target"
|
||||
${pkgs.coreutils}/bin/chmod 0640 "$settings_target"
|
||||
|
||||
@@ -239,7 +250,8 @@ PY_PI_SETTINGS_MERGE
|
||||
${pkgs.coreutils}/bin/cat ${escapeShellArg f} >> "$env_target"
|
||||
printf '\n' >> "$env_target"
|
||||
fi
|
||||
'') cfg.environmentFiles)}
|
||||
'')
|
||||
cfg.environmentFiles)}
|
||||
|
||||
${pkgs.coreutils}/bin/chown ${escapeShellArg "${cfg.user}:${cfg.group}"} "$env_target"
|
||||
${pkgs.coreutils}/bin/chmod 0640 "$env_target"
|
||||
@@ -410,8 +422,10 @@ PY_PI_SETTINGS_MERGE
|
||||
printf '%s\n' "$user_home"
|
||||
elif ${pkgs.gnugrep}/bin/grep -q '^~/' <<<"$input"; then
|
||||
printf '%s\n' "$user_home/''${input:2}"
|
||||
else
|
||||
elif ${pkgs.gnugrep}/bin/grep -q '^/' <<<"$input"; then
|
||||
printf '%s\n' "$input"
|
||||
else
|
||||
printf '%s\n' "$user_home/$input"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -657,7 +671,8 @@ in {
|
||||
++ mapAttrsToList (user: userCfg: {
|
||||
assertion = userCfg.projectRoots != [];
|
||||
message = "m3ta.pi-agent.hostUsers.${user}.projectRoots must not be empty.";
|
||||
}) cfg.hostUsers;
|
||||
})
|
||||
cfg.hostUsers;
|
||||
|
||||
users.groups = mkIf cfg.createUser {
|
||||
"${cfg.group}" = {};
|
||||
|
||||
Reference in New Issue
Block a user