Skip to content

Commit

Permalink
add for 'flake check' as well
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Dec 15, 2024
1 parent b40459b commit ccb66ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
10 changes: 10 additions & 0 deletions crates/nix_rs/src/flake/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ pub async fn lock(
Ok(())
}

/// Run `nix flake check`
pub async fn check(cmd: &NixCmd, opts: &FlakeOptions, url: &FlakeUrl) -> Result<(), NixCmdError> {
cmd.run_with(|c| {
opts.use_in_command(c);
c.args(["flake", "check", url]);
})
.await?;
Ok(())
}

/// A path built by nix, as returned by --print-out-paths
#[derive(Serialize, Deserialize)]
pub struct OutPath {
Expand Down
19 changes: 9 additions & 10 deletions crates/omnix-ci/src/step/flake_check.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! The cachix step
use colored::Colorize;
use nix_rs::{command::NixCmd, flake::url::FlakeUrl};
use nix_rs::{
command::NixCmd,
flake::{self, command::FlakeOptions, url::FlakeUrl},
};
use serde::Deserialize;

use crate::config::subflake::SubflakeConfig;
Expand Down Expand Up @@ -33,15 +36,11 @@ impl FlakeCheckStep {
format!("🩺 Running flake check on: {}", subflake.dir).bold()
);
let sub_flake_url = url.sub_flake_url(subflake.dir.clone());
let mut args = vec!["flake", "check", &sub_flake_url];
for (k, v) in &subflake.override_inputs {
args.extend(["--override-input", k, v]);
}
nixcmd
.run_with(|cmd| {
cmd.args(args);
})
.await?;
let opts = FlakeOptions {
override_inputs: subflake.override_inputs.clone(),
..Default::default()
};
flake::command::check(nixcmd, &opts, &sub_flake_url).await?;
Ok(())
}
}

0 comments on commit ccb66ec

Please sign in to comment.