From 0652925521a97d4ef020ca39ca26fc1558a0895b Mon Sep 17 00:00:00 2001 From: "Timothy J. Aveni" Date: Tue, 30 Jun 2026 07:14:09 -0700 Subject: [PATCH] Run user-data switch in transient unit --- user-data.sh.tftpl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/user-data.sh.tftpl b/user-data.sh.tftpl index 0f9cd00..7f6a7dc 100644 --- a/user-data.sh.tftpl +++ b/user-data.sh.tftpl @@ -120,7 +120,7 @@ write_final_config() { wantedBy = [ "multi-user.target" ]; after = [ "fetch-ec2-metadata.service" "network-online.target" "nix-daemon.socket" ]; wants = [ "fetch-ec2-metadata.service" "network-online.target" "nix-daemon.socket" ]; - path = [ pkgs.coreutils pkgs.git ]; + path = [ pkgs.coreutils pkgs.git pkgs.systemd ]; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; @@ -146,8 +146,23 @@ write_final_config() { fi install -m 0644 "$user_data" /etc/nixos/flake.nix + + runner=/run/nixos-user-data-flake-apply + cat > "$runner" < "$applied_hash_file" +RUNNER_EOF + chmod 0700 "$runner" + + systemd-run \ + --unit=nixos-user-data-flake-apply \ + --collect \ + --no-ask-password \ + --service-type=exec \ + "$${pkgs.runtimeShell}" "$runner" ''; };