Clippy: nix: borrow the op
This commit is contained in:
parent
f2030c2ee5
commit
d49bd4495a
4 changed files with 17 additions and 17 deletions
|
@ -28,7 +28,7 @@ impl EvalChecker {
|
||||||
|
|
||||||
pub fn execute(&self, path: &Path) -> Result<File, File> {
|
pub fn execute(&self, path: &Path) -> Result<File, File> {
|
||||||
self.nix
|
self.nix
|
||||||
.safely(self.op.clone(), path, self.args.clone(), false)
|
.safely(&self.op, path, self.args.clone(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cli_cmd(&self) -> String {
|
pub fn cli_cmd(&self) -> String {
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl Nix {
|
||||||
attrargs.push(attr);
|
attrargs.push(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.safe_command(Operation::Instantiate, nixpkgs, attrargs)
|
self.safe_command(&Operation::Instantiate, nixpkgs, attrargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn safely_build_attrs(
|
pub fn safely_build_attrs(
|
||||||
|
@ -188,17 +188,17 @@ impl Nix {
|
||||||
attrargs.push(attr);
|
attrargs.push(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.safe_command(Operation::Build, nixpkgs, attrargs)
|
self.safe_command(&Operation::Build, nixpkgs, attrargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn safely(
|
pub fn safely(
|
||||||
&self,
|
&self,
|
||||||
op: Operation,
|
op: &Operation,
|
||||||
nixpkgs: &Path,
|
nixpkgs: &Path,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
keep_stdout: bool,
|
keep_stdout: bool,
|
||||||
) -> Result<File, File> {
|
) -> Result<File, File> {
|
||||||
self.run(self.safe_command(op, nixpkgs, args), keep_stdout)
|
self.run(self.safe_command(&op, nixpkgs, args), keep_stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&self, mut cmd: Command, keep_stdout: bool) -> Result<File, File> {
|
pub fn run(&self, mut cmd: Command, keep_stdout: bool) -> Result<File, File> {
|
||||||
|
@ -228,7 +228,7 @@ impl Nix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn safe_command(&self, op: Operation, nixpkgs: &Path, args: Vec<String>) -> Command {
|
pub fn safe_command(&self, op: &Operation, nixpkgs: &Path, args: Vec<String>) -> Command {
|
||||||
let nixpath = format!("nixpkgs={}", nixpkgs.display());
|
let nixpath = format!("nixpkgs={}", nixpkgs.display());
|
||||||
|
|
||||||
let mut command = op.command();
|
let mut command = op.command();
|
||||||
|
@ -419,7 +419,7 @@ mod tests {
|
||||||
assert_eq!(op.to_string(), "nix-build");
|
assert_eq!(op.to_string(), "nix-build");
|
||||||
|
|
||||||
let ret: Result<File, File> = nix.run(
|
let ret: Result<File, File> = nix.run(
|
||||||
nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]),
|
nix.safe_command(&op, build_path().as_path(), vec![String::from("--version")]),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ mod tests {
|
||||||
assert_eq!(op.to_string(), "nix-instantiate");
|
assert_eq!(op.to_string(), "nix-instantiate");
|
||||||
|
|
||||||
let ret: Result<File, File> = nix.run(
|
let ret: Result<File, File> = nix.run(
|
||||||
nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]),
|
nix.safe_command(&op, build_path().as_path(), vec![String::from("--version")]),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ mod tests {
|
||||||
assert_eq!(op.to_string(), "nix-env -qa --json");
|
assert_eq!(op.to_string(), "nix-env -qa --json");
|
||||||
|
|
||||||
let ret: Result<File, File> = nix.run(
|
let ret: Result<File, File> = nix.run(
|
||||||
nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]),
|
nix.safe_command(&op, build_path().as_path(), vec![String::from("--version")]),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ mod tests {
|
||||||
assert_eq!(op.to_string(), "nix-env -qaP --no-name --out-path");
|
assert_eq!(op.to_string(), "nix-env -qaP --no-name --out-path");
|
||||||
|
|
||||||
let ret: Result<File, File> = nix.run(
|
let ret: Result<File, File> = nix.run(
|
||||||
nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]),
|
nix.safe_command(&op, build_path().as_path(), vec![String::from("--version")]),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ mod tests {
|
||||||
let nix = nix();
|
let nix = nix();
|
||||||
|
|
||||||
let ret: Result<File, File> = nix.run(
|
let ret: Result<File, File> = nix.run(
|
||||||
nix.safe_command(env_noop(), build_path().as_path(), vec![]),
|
nix.safe_command(&env_noop(), build_path().as_path(), vec![]),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let ret: Result<File, File> = nix.run(
|
let ret: Result<File, File> = nix.run(
|
||||||
nix.safe_command(env_noop(), build_path().as_path(), vec![]),
|
nix.safe_command(&env_noop(), build_path().as_path(), vec![]),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@ mod tests {
|
||||||
let op = noop(Operation::Build);
|
let op = noop(Operation::Build);
|
||||||
|
|
||||||
let ret: Result<File, File> =
|
let ret: Result<File, File> =
|
||||||
nix.run(nix.safe_command(op, build_path().as_path(), vec![]), true);
|
nix.run(nix.safe_command(&op, build_path().as_path(), vec![]), true);
|
||||||
|
|
||||||
assert_run(
|
assert_run(
|
||||||
ret,
|
ret,
|
||||||
|
@ -668,7 +668,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn instantiation_success() {
|
fn instantiation_success() {
|
||||||
let ret: Result<File, File> = nix().safely(
|
let ret: Result<File, File> = nix().safely(
|
||||||
Operation::Instantiate,
|
&Operation::Instantiate,
|
||||||
passing_eval_path().as_path(),
|
passing_eval_path().as_path(),
|
||||||
vec![],
|
vec![],
|
||||||
true,
|
true,
|
||||||
|
@ -688,7 +688,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn instantiation_nixpkgs_restricted_mode() {
|
fn instantiation_nixpkgs_restricted_mode() {
|
||||||
let ret: Result<File, File> = nix().safely(
|
let ret: Result<File, File> = nix().safely(
|
||||||
Operation::Instantiate,
|
&Operation::Instantiate,
|
||||||
individual_eval_path().as_path(),
|
individual_eval_path().as_path(),
|
||||||
vec![String::from("-A"), String::from("nixpkgs-restricted-mode")],
|
vec![String::from("-A"), String::from("nixpkgs-restricted-mode")],
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl OutPaths {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.nix.safely(
|
self.nix.safely(
|
||||||
nix::Operation::QueryPackagesOutputs,
|
&nix::Operation::QueryPackagesOutputs,
|
||||||
&self.path,
|
&self.path,
|
||||||
vec![
|
vec![
|
||||||
String::from("-f"),
|
String::from("-f"),
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl Stdenvs {
|
||||||
/// given system.
|
/// given system.
|
||||||
fn evalstdenv(&self, system: &str) -> Option<String> {
|
fn evalstdenv(&self, system: &str) -> Option<String> {
|
||||||
let result = self.nix.with_system(system.to_owned()).safely(
|
let result = self.nix.with_system(system.to_owned()).safely(
|
||||||
nix::Operation::QueryPackagesOutputs,
|
&nix::Operation::QueryPackagesOutputs,
|
||||||
&self.co,
|
&self.co,
|
||||||
vec![
|
vec![
|
||||||
String::from("-f"),
|
String::from("-f"),
|
||||||
|
|
Loading…
Reference in a new issue