cli: Support passing --impure
This commit is contained in:
parent
8aca525788
commit
80426aa814
4 changed files with 27 additions and 0 deletions
|
@ -124,6 +124,12 @@ pub fn build_cli(include_internal: bool) -> ClapCommand<'static> {
|
|||
.long_help("Passes --show-trace to Nix commands")
|
||||
.global(true)
|
||||
.takes_value(false))
|
||||
.arg(Arg::new("impure")
|
||||
.long("impure")
|
||||
.help("Allow impure expressions")
|
||||
.long_help("Passes --impure to Nix commands")
|
||||
.global(true)
|
||||
.takes_value(false))
|
||||
.arg(Arg::new("color")
|
||||
.long("color")
|
||||
.help("When to colorize the output")
|
||||
|
|
|
@ -49,6 +49,9 @@ pub struct Hive {
|
|||
/// Whether to pass --show-trace in Nix commands.
|
||||
show_trace: bool,
|
||||
|
||||
/// Whether to pass --impure in Nix commands.
|
||||
impure: bool,
|
||||
|
||||
meta_config: OnceCell<MetaConfig>,
|
||||
}
|
||||
|
||||
|
@ -100,6 +103,7 @@ impl Hive {
|
|||
context_dir,
|
||||
assets,
|
||||
show_trace: false,
|
||||
impure: false,
|
||||
meta_config: OnceCell::new(),
|
||||
})
|
||||
}
|
||||
|
@ -123,11 +127,16 @@ impl Hive {
|
|||
self.show_trace = value;
|
||||
}
|
||||
|
||||
pub fn set_impure(&mut self, impure: bool) {
|
||||
self.impure = impure;
|
||||
}
|
||||
|
||||
/// Returns Nix options to set for this Hive.
|
||||
pub fn nix_options(&self) -> NixOptions {
|
||||
let mut options = NixOptions::default();
|
||||
options.set_show_trace(self.show_trace);
|
||||
options.set_pure_eval(self.path.is_flake());
|
||||
options.set_impure(self.impure);
|
||||
options
|
||||
}
|
||||
|
||||
|
|
|
@ -197,6 +197,10 @@ impl NixOptions {
|
|||
self.pure_eval = pure_eval;
|
||||
}
|
||||
|
||||
pub fn set_impure(&mut self, impure: bool) {
|
||||
self.impure = impure;
|
||||
}
|
||||
|
||||
pub fn set_builders(&mut self, builders: Option<String>) {
|
||||
self.builders = builders;
|
||||
}
|
||||
|
|
|
@ -250,6 +250,10 @@ pub async fn hive_from_args(args: &ArgMatches) -> ColmenaResult<Hive> {
|
|||
hive.set_show_trace(true);
|
||||
}
|
||||
|
||||
if args.is_present("impure") {
|
||||
hive.set_impure(true);
|
||||
}
|
||||
|
||||
return Ok(hive);
|
||||
}
|
||||
|
||||
|
@ -273,6 +277,10 @@ pub async fn hive_from_args(args: &ArgMatches) -> ColmenaResult<Hive> {
|
|||
hive.set_show_trace(true);
|
||||
}
|
||||
|
||||
if args.is_present("impure") {
|
||||
hive.set_impure(true);
|
||||
}
|
||||
|
||||
Ok(hive)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue