Skip to content

Commit 31a1b3b

Browse files
committed
Skip nixos-rebuild re-exec when running from bundled flake
nixos-rebuild's re-exec mechanism builds $flake#nixosConfigurations.$host.config.system.build.nixos-rebuild before switching. When BLOUD_FLAKE_PATH points to the bundled store path, this evaluates to the bloud-host-agent package (not nixos-rebuild), causing exec to fail with no such binary. Setting _NIXOS_REBUILD_REEXEC=1 bypasses this step so the already-running nixos-rebuild binary is used directly.
1 parent 91e763a commit 31a1b3b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Home Cloud Operating System**
44

5-
An opinionated, zero-config home server OS that makes self-hosting actually accessible. Install apps with automatic SSO integration—no manual OAuth configuration, no reverse proxy setup.
5+
An opinionated, zero-config home server OS that makes self-hosting accessible. Install apps with automatic SSO integration. No manual OAuth configuration, reverse proxy setup, or integration configurations.
66

77
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](LICENSE)
88
[![Status: Alpha](https://img.shields.io/badge/Status-Alpha-orange.svg)]()

screenshots/login.png

-33.6 KB
Binary file not shown.

services/host-agent/internal/nixgen/rebuild.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io"
88
"log/slog"
9+
"os"
910
"os/exec"
1011
"strings"
1112
"time"
@@ -74,6 +75,13 @@ func (r *Rebuilder) Switch(ctx context.Context) (*RebuildResult, error) {
7475
cmd = exec.CommandContext(ctx, "/run/current-system/sw/bin/nixos-rebuild", args...)
7576
}
7677

78+
// Skip nixos-rebuild's re-exec mechanism: it tries to build
79+
// $flake#nixosConfigurations.$host.config.system.build.nixos-rebuild and
80+
// re-exec from there. When BLOUD_FLAKE_PATH points to a bundled store path,
81+
// this resolves to the bloud-host-agent package (not nixos-rebuild).
82+
// Setting _NIXOS_REBUILD_REEXEC=1 skips that step.
83+
cmd.Env = append(os.Environ(), "_NIXOS_REBUILD_REEXEC=1")
84+
7785
// Capture both stdout and stderr
7886
stdout, err := cmd.StdoutPipe()
7987
if err != nil {
@@ -241,6 +249,7 @@ func (r *Rebuilder) SwitchStream(ctx context.Context, events chan<- RebuildEvent
241249
} else {
242250
cmd = exec.CommandContext(ctx, "/run/current-system/sw/bin/nixos-rebuild", args...)
243251
}
252+
cmd.Env = append(os.Environ(), "_NIXOS_REBUILD_REEXEC=1")
244253

245254
stdout, err := cmd.StdoutPipe()
246255
if err != nil {

0 commit comments

Comments
 (0)