diff --git a/modules/wafrn.nix b/modules/wafrn.nix index e11ec40..bdfe939 100644 --- a/modules/wafrn.nix +++ b/modules/wafrn.nix @@ -456,6 +456,7 @@ in serviceConfig = { Type = "oneshot"; RemainAfterExit = true; + TimeoutStartSec = "30min"; }; script = '' set -euo pipefail @@ -478,10 +479,25 @@ in exit 1 fi - rm -rf "${preparedSourcePath}" - mkdir -p "${preparedSourcePath}" - cp -a "$selected_source/." "${preparedSourcePath}/" - chmod -R u+w "${preparedSourcePath}" + marker_file="${preparedSourcePath}/.wafrn-source-origin" + need_refresh=1 + if [ -f "$marker_file" ]; then + if [ "$(cat "$marker_file")" = "$selected_source" ]; then + need_refresh=0 + fi + fi + + if [ "$need_refresh" -eq 1 ]; then + echo "wafrn-nix: preparing source tree from $selected_source" >&2 + rm -rf "${preparedSourcePath}" + mkdir -p "${preparedSourcePath}" + cp -a "$selected_source/." "${preparedSourcePath}/" + chmod -R u+w "${preparedSourcePath}" + printf '%s' "$selected_source" > "$marker_file" + else + echo "wafrn-nix: reusing prepared source tree" >&2 + chmod -R u+w "${preparedSourcePath}" + fi if [ ! -e "${preparedSourcePath}/.git" ]; then mkdir -p "${preparedSourcePath}/.git"