create container

This commit is contained in:
stubbfelnewpc
2020-07-07 22:35:17 +02:00
parent ffbb5ce424
commit 13b50650fa
3 changed files with 71 additions and 37 deletions

View File

@@ -161,19 +161,6 @@ impl NixIdeManageServiceEngine for PodmanEngineTraitImpl {
Ok(IdeState::OPENING)
}
}
// println!("foo {:x}", hash);
// let out = Command::new("podman")
// .arg("create")
// .arg("--name")
// .arg(format!("{:x}", hash))
// .arg("-p")
// .arg("3000:3000")
// .arg("docker.io/nixos/nix")
// // .arg(format!("git clone {}", param.clone_url))
// .output()
// .expect("create container");
// String::from_utf8(out.stderr).unwrap()
}
}
@@ -286,6 +273,52 @@ fn working_thread(thread_param: &ThreadRunningParam) -> Result<(), Error> {
}
_ => {}
};
let port = thread_param.container.ide_param.listen_port;
let nix_expression = format!("with import <nixpkgs> {{}}; callPackage /nixide/repo/.nixide/start-ide.nix {{listenPort = {}; projectFolder = \"/nixide/repo\"; }}", port);
let out = Command::new("podman")
.current_dir(ide_folder)
.arg("create")
.arg("--name")
.arg(ide_id)
.arg("-p")
.arg(format!("{}:{}", port, port))
.arg("-v")
.arg(format!("{}:/nixide", ide_folder))
.arg("-w")
.arg("/nixide")
.arg("docker.io/nixos/nix")
.arg("nix-shell")
.arg("--expr")
.arg(nix_expression)
.arg("--pure")
.arg("--run")
.arg("run_ide.sh")
.status().map_err(|_| Error{})?;
// let nix_expression = format!("with import <nixpkgs> {{}}; callPackage {} {}", file, args);
// let cmd = Command::new("nix-shell")
// .stderr(Stdio::null())
// //.stdout(Stdio::null())
// .stdout(Stdio::piped())
// .arg("--expr")
// .arg(nix_expression)
// .arg("--pure")
// .arg("--run")
// .arg(run_script)
// .spawn()
// .expect("start ide command failed");
// podman create --name test -p 3000:3000 -v $PWD:/nixide -w /nixide docker.io/nixos/nix nix-shell --pure start-ide.nix --run run_ide.sh
// .arg("create")
// .arg("--name")
// .arg(format!("{:x}", hash))
// .arg("-p")
// .arg("3000:3000")
// .arg("docker.io/nixos/nix")
// // .arg(format!("git clone {}", param.clone_url))
// .output()
//
// String::from_utf8(out.stderr).unwrap()
Ok(())
}