Skip to content

fix: stream build logs when -L is passed - #387

Merged
Sereja313 merged 2 commits into
masterfrom
sereja/fix-build-logs
Aug 4, 2026
Merged

fix: stream build logs when -L is passed#387
Sereja313 merged 2 commits into
masterfrom
sereja/fix-build-logs

Conversation

@Sereja313

Copy link
Copy Markdown
Member

Problem: Recent async build feature broke -L/--print-build-logs.

Solution: When -L is set, stream each build-log line above the bar, prefixed with the derivation name like native nix build -L.

@Sereja313
Sereja313 force-pushed the sereja/fix-build-logs branch 2 times, most recently from d4a7259 to 89acd6f Compare July 30, 2026 22:22
Comment thread src/push.rs Outdated
Comment on lines +245 to +260
fn enabled_build_logs(extra_build_args: &[String]) -> bool {
extra_build_args
.iter()
.any(|a| a == "-L" || a == "--print-build-logs")
}

fn drv_name(drv_path: &str) -> String {
let base = drv_path.rsplit('/').next().unwrap_or(drv_path);
let base = base.strip_suffix(".drv").unwrap_or(base);
let name_ver = base.split_once('-').map(|(_, r)| r).unwrap_or(base);
let bytes = name_ver.as_bytes();
let cut = (0..bytes.len())
.find(|&i| bytes[i] == b'-' && bytes.get(i + 1).is_some_and(u8::is_ascii_digit))
.unwrap_or(name_ver.len());
name_ver[..cut].to_string()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels very fragile - I think this is the only place where deploy has to parse the nix command line, and then you are doing a bunch of work to recreate similar log output to Nix.

Could you maybe get 99% of the way there just by modifying cli.rs to not set data.deploy_data.progressbar = Some(pb.clone()); when there are no remote builds? It looks like that would result in nix build's normal log output appearing on the terminal for local builds, which already are done synchronously.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, I removed it everywhere except in the case of multiple remote builds.

Problem: The progress bar consumes nix's output, so local and
single-host deploys lost native -L logs, errors and progress.

Solution: Only show the spinner when building on multiple remote hosts
at once, otherwise let nix write its native output directly.
Problem: With the spinner shown (2+ remote hosts), a failed build
printed only a bare exit code, hiding nix's error.

Solution: Print nix error/warning messages above the bar so failures
show their reason.
@Sereja313
Sereja313 force-pushed the sereja/fix-build-logs branch from 89acd6f to 0a3af8b Compare July 31, 2026 16:06
@Sereja313
Sereja313 merged commit 5059116 into master Aug 4, 2026
34 of 39 checks passed
@Sereja313
Sereja313 deleted the sereja/fix-build-logs branch August 4, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants