Created
June 13, 2020 00:36
-
-
Save lovesegfault/2c2c490be072227debaeb584ed32ad81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod nix; | |
use nix::NixShellTemplateBuilder; | |
use std::io::Write; | |
use std::process::Command; | |
use tempfile::NamedTempFile; | |
fn main() -> Result<(), Box<dyn std::error::Error>> { | |
let rust_shell = NixShellTemplateBuilder::default() | |
.name("Rust") | |
.build_inputs(&["rust-analyzer", "cargo"][..]) | |
.shell_hook("echo 'foo'") | |
.build()? | |
.render(); | |
let mut tmp_shell_file = NamedTempFile::new()?; | |
tmp_shell_file.write_all(rust_shell.as_bytes())?; | |
Command::new("nix-shell") | |
.arg(tmp_shell_file.path()) | |
.status()?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment