Run nix build.
This commit is contained in:
@@ -6,6 +6,7 @@ use crate::fs_util::assert_directory;
|
||||
use crate::fs_util::is_git_repo;
|
||||
use crate::git_util::git_force_into_state;
|
||||
use crate::git_util::git_init_at_rev;
|
||||
use crate::nix_util::nixos_build_target;
|
||||
|
||||
pub(crate) async fn run_build(args: BuildArgs) -> Result<(), CustomError> {
|
||||
println!("{:?}", args);
|
||||
@@ -23,6 +24,7 @@ pub(crate) async fn run_build(args: BuildArgs) -> Result<(), CustomError> {
|
||||
};
|
||||
|
||||
prepare_flake_repo(&config, target_config).await?;
|
||||
build_target(&config, target_config).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -32,17 +34,17 @@ async fn prepare_flake_repo(
|
||||
config_root: &Config,
|
||||
target_config: &TargetConfig,
|
||||
) -> Result<(), CustomError> {
|
||||
let flake_directory = target_config.get_flake_directory(config_root)?;
|
||||
let repo_directory = target_config.get_repo_directory(config_root)?;
|
||||
assert_directory!(
|
||||
&flake_directory,
|
||||
"Creating flake directory {}",
|
||||
(&flake_directory).to_string_lossy()
|
||||
&repo_directory,
|
||||
"Creating repo directory {}",
|
||||
(&repo_directory).to_string_lossy()
|
||||
);
|
||||
|
||||
if is_git_repo(&flake_directory).await? {
|
||||
if is_git_repo(&repo_directory).await? {
|
||||
// Clean up the existing clone
|
||||
git_force_into_state(
|
||||
&flake_directory,
|
||||
&repo_directory,
|
||||
target_config.get_branch()?,
|
||||
"origin",
|
||||
target_config.get_repo()?,
|
||||
@@ -51,7 +53,7 @@ async fn prepare_flake_repo(
|
||||
.await?;
|
||||
} else {
|
||||
git_init_at_rev(
|
||||
&flake_directory,
|
||||
&repo_directory,
|
||||
target_config.get_branch()?,
|
||||
target_config.get_repo()?,
|
||||
target_config.get_revision()?,
|
||||
@@ -60,3 +62,20 @@ async fn prepare_flake_repo(
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn build_target(
|
||||
config_root: &Config,
|
||||
target_config: &TargetConfig,
|
||||
) -> Result<(), CustomError> {
|
||||
let flake_directory = target_config.get_flake_directory(config_root)?;
|
||||
let build_directory = target_config.get_build_directory(config_root)?;
|
||||
assert_directory!(
|
||||
&build_directory,
|
||||
"Creating build directory {}",
|
||||
(&build_directory).to_string_lossy()
|
||||
);
|
||||
|
||||
nixos_build_target(build_directory, flake_directory, target_config.get_attr()?).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user