Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use --quiet --quiet by default for om ci and om show #324

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
Next Next commit
Use --quiet --quiet by default for om ci and om show
shivaraj-bh committed Oct 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6cc690c8b64b010fb435873be296e83ae456a044
1 change: 1 addition & 0 deletions crates/nix_rs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

## Unreleased

- Add `NixCmd::extra_args`
- **`eval::nix_eval`**
- Display evaluation progress
- Decrease logging verbosity
12 changes: 12 additions & 0 deletions crates/nix_rs/src/command.rs
Original file line number Diff line number Diff line change
@@ -40,6 +40,10 @@ pub struct NixCmd {
#[cfg_attr(feature = "clap", arg(long))]
pub extra_access_tokens: Vec<String>,

/// Arguments to pass verbatim to the Nix command
#[cfg_attr(feature = "clap", arg(long))]
pub extra_args: Vec<String>,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of extra_args, just add a quiet field looking like this. It is more self-documenting.

https://github.com/clap-rs/clap-verbosity-flag/blob/a7e305e8b0bde21be222ae658cc14813464ea3e6/src/lib.rs#L79-L88


/// Consider all previously downloaded files out-of-date.
#[cfg_attr(feature = "clap", arg(long))]
pub refresh: bool,
@@ -57,6 +61,7 @@ impl Default for NixCmd {
Self {
extra_experimental_features: vec![],
extra_access_tokens: vec![],
extra_args: vec![],
refresh: false,
command: None,
}
@@ -119,6 +124,13 @@ impl NixCmd {
cmd
}

/// Suppress logs related to `override-input` usage.
pub fn mute_override_input_logs(&mut self) {
// Yes, this requires *double* use of `--quiet`. Also, `-qq` won't work until https://github.com/NixOS/nix/pull/11652
self.extra_args
.extend(vec!["--quiet".to_string(), "--quiet".to_string()]);
}

/// Run nix with given args, interpreting stdout as JSON, parsing into `T`
pub async fn run_with_args_expecting_json<T>(&self, args: &[&str]) -> Result<T, NixCmdError>
where
5 changes: 4 additions & 1 deletion crates/omnix-cli/src/command/ci.rs
Original file line number Diff line number Diff line change
@@ -17,8 +17,11 @@ pub struct CICommand {
impl CICommand {
/// Run this sub-command
pub async fn run(&self, verbosity: Verbosity<InfoLevel>) -> anyhow::Result<()> {
let mut nixcmd = self.nixcmd.clone();
nixcmd.mute_override_input_logs();

self.command()
.run(&self.nixcmd, verbosity.log_level() > Some(Level::Info))
.run(&nixcmd, verbosity.log_level() > Some(Level::Info))
.await?;
Ok(())
}
6 changes: 4 additions & 2 deletions crates/omnix-cli/src/command/show.rs
Original file line number Diff line number Diff line change
@@ -90,10 +90,12 @@ impl Row {

impl ShowCommand {
pub async fn run(&self) -> anyhow::Result<()> {
let nix_cmd = NixCmd::get().await;
let mut nix_cmd = NixCmd::get().await.clone();
nix_cmd.mute_override_input_logs();

let nix_config = NixConfig::get().await.as_ref()?;
let system = &nix_config.system.value;
let flake = Flake::from_nix(nix_cmd, nix_config, self.flake_url.clone())
let flake = Flake::from_nix(&nix_cmd, nix_config, self.flake_url.clone())
.await
.with_context(|| "Unable to fetch flake")?;

2 changes: 2 additions & 0 deletions doc/src/history.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

## Unreleased

- `om ci`: Suppress logs from `--override-input` usage

### Enhancements

- `om hack`: New command