Skip to content

Commit 968c12b

Browse files
committed
checks: warn instead of error if environment checks fail
1 parent 4e9982c commit 968c12b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/checks.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{cmp::Ordering, env};
22

33
use color_eyre::{eyre, Result};
44
use semver::Version;
5+
use tracing::warn;
56

67
use crate::util;
78

@@ -48,12 +49,13 @@ pub fn check_nix_version() -> Result<()> {
4849
match current.cmp(&required) {
4950
Ordering::Less => {
5051
let binary_name = if is_lix_binary { "Lix" } else { "Nix" };
51-
Err(eyre::eyre!(
52-
"{} version {} is too old. Minimum required version is {}",
52+
warn!(
53+
"Warning: {} version {} is older than the recommended minimum version {}. You may encounter issues.",
5354
binary_name,
5455
version,
5556
min_version
56-
))
57+
);
58+
Ok(())
5759
}
5860
_ => Ok(()),
5961
}

src/main.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ const NH_VERSION: &str = env!("CARGO_PKG_VERSION");
2121
const NH_REV: Option<&str> = option_env!("NH_REV");
2222

2323
fn main() -> Result<()> {
24-
let do_warn = checks::setup_environment()?;
25-
2624
let args = <crate::interface::Main as clap::Parser>::parse();
25+
26+
// Set up logging
2727
crate::logging::setup_logging(args.verbose)?;
2828
tracing::debug!("{args:#?}");
2929
tracing::debug!(%NH_VERSION, ?NH_REV);
3030

31-
if do_warn {
31+
// Verify the Nix environment before running commands
32+
checks::verify_nix_environment()?;
33+
34+
// Once we assert required Nix features, validate NH environment checks
35+
// For now, this is just NH_* variables being set. More checks may be
36+
// added to setup_environment in the future.
37+
if checks::setup_environment()? {
3238
tracing::warn!(
3339
"nh {NH_VERSION} now uses NH_FLAKE instead of FLAKE, please modify your configuration"
3440
);
3541
}
3642

37-
// Verify the Nix environment before running commands
38-
checks::verify_nix_environment()?;
39-
4043
args.command.run()
4144
}
4245

0 commit comments

Comments
 (0)