mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2024-11-22 04:45:20 +00:00
Use target_nix
when running xtasks in Nix
This commit is contained in:
parent
b71d33b5c1
commit
e6bc1576ca
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@
|
|||||||
# Compiled files and executables
|
# Compiled files and executables
|
||||||
debug/
|
debug/
|
||||||
target/
|
target/
|
||||||
|
target_nix/
|
||||||
|
|
||||||
# Backup files generated by rustfmt
|
# Backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
@ -8,11 +8,10 @@ use std::path::PathBuf;
|
|||||||
use std::process::{self, Command};
|
use std::process::{self, Command};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let nix_enabled = enable_nix();
|
|
||||||
|
|
||||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
let dir = dir.parent().with_context(|| format!("could not find workspace root: {}", dir.display()))?;
|
let dir = dir.parent().with_context(|| format!("could not find workspace root: {}", dir.display()))?;
|
||||||
env::set_current_dir(dir).with_context(|| format!("could not set current directory: {}", dir.display()))?;
|
env::set_current_dir(dir).with_context(|| format!("could not set current directory: {}", dir.display()))?;
|
||||||
|
let nix_enabled = enable_nix();
|
||||||
|
|
||||||
let app = App::parse();
|
let app = App::parse();
|
||||||
match app {
|
match app {
|
||||||
@ -147,8 +146,11 @@ fn enable_nix() -> bool {
|
|||||||
println!("Detected Nix in environment, re-running in Nix.");
|
println!("Detected Nix in environment, re-running in Nix.");
|
||||||
let args = env::args();
|
let args = env::args();
|
||||||
let cmd = shell_words::join(args);
|
let cmd = shell_words::join(args);
|
||||||
let mut nix_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
||||||
nix_path.push("../shell.nix");
|
let status = Command::new("nix-shell")
|
||||||
let status = Command::new("nix-shell").args(&["--pure", "--run", &cmd, "--"]).arg(nix_path).status().unwrap();
|
.args(&["--pure", "--run", &cmd, "--", "shell.nix"])
|
||||||
|
.env("CARGO_TARGET_DIR", "target_nix")
|
||||||
|
.status()
|
||||||
|
.unwrap();
|
||||||
process::exit(status.code().unwrap_or(1));
|
process::exit(status.code().unwrap_or(1));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user