Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 34 additions & 11 deletions src/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ pub(crate) struct Build {
/// The specific Nix system to build for (otherwise infer the current system from arch/OS information).
#[arg(short, long, env = "FLAKE_ITER_NIX_SYSTEM")]
system: Option<String>,

/// Number of concurrent Nix builds
#[arg(short = 'j', long, env = "FLAKE_ITER_BUILD_JOBS")]
build_jobs: Option<usize>,

/// Number of cores to utilize per job
#[arg(short = 'c', long, env = "FLAKE_ITER_BUILD_CORES")]
build_cores: Option<usize>,
}

impl Build {
Expand Down Expand Up @@ -88,19 +96,34 @@ impl Build {
}
}

let mut args: Vec<String> =
vec![String::from("build"), String::from("--print-out-paths")];

if let Some(cores) = &self.build_cores {
let cores = cores.to_string();
args.push(String::from("--cores"));
args.push(cores);
}

if let Some(max_jobs) = &self.build_jobs {
let max_jobs = max_jobs.to_string();
args.push(String::from("--max-jobs"));
args.push(max_jobs);
}

if verbose {
args.push(String::from("--print-build-logs"));
}

args.push(drv);

let args: Vec<&str> = args.iter().map(String::as_str).collect();

info!("Building derivation {} of {num}", n + 1);
if verbose {
debug!(drv, "Building derivation {} of {num}", n + 1);
nix_command_pipe_no_output(&[
"build",
"--print-out-paths",
"--print-build-logs",
&drv,
])
.wrap_err("failed to build derivation")?;
nix_command_pipe_no_output(&args).wrap_err("failed to build derivation")?;
} else {
info!("Building derivation {} of {num}", n + 1);
nix_command(&["build", "--print-out-paths", &drv])
.wrap_err("failed to build derivation")?;
nix_command(&args).wrap_err("failed to build derivation")?;
}
}

Expand Down
Loading