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

@@ -1,4 +1,5 @@
{
# nix-shell --expr 'with import <nixpkgs> {}; callPackage start_ide.nix {}' --pure --run run_ide.sh
{
pkgs ? import <nixpkgs> {},
listenAddress ? "0.0.0.0",
listenPort ? 3000,
@@ -11,19 +12,19 @@ let
nodejs = pkgs.nodejs-10_x;
yarn' = pkgs.yarn.override { inherit nodejs; };
theiaideBuildDependencies = [
pkgs.nano
pkgs.curl
yarn'
pkgs.nano
pkgs.curl
yarn'
nodejs
pkgs.python27Full
pkgs.git
pkgs.wget
pkgs.lzma
pkgs.python27Full
pkgs.git
pkgs.wget
pkgs.lzma
pkgs.gcc
pkgs.gnumake
pkgs.gccStdenv
pkgs.binutils
pkgs.gnupg
pkgs.gnupg
];
projectDependencies = [
@@ -33,15 +34,15 @@ let
pkgs.clippy
pkgs.rustfmt
pkgs.rustup
];
];
theiaidePackageConfig = {
private= true;
theia.frontend.config.applicationName = "DevelNixos";
dependencies = {
theia.frontend.config.applicationName = "DevelNixos";
dependencies = {
"@theia/callhierarchy" = "latest";
"@theia/console" = "latest";
"@theia/core" = "latest";
"@theia/core" = "latest";
"@theia/editor" = "latest";
"@theia/editor-preview" = "latest";
"@theia/file-search" = "latest";
@@ -74,7 +75,7 @@ let
"@theia/vsx-registry" = "latest";
"@theia/workspace" = "latest";
};
theiaPlugins = {
theiaPlugins = {
vscode-builtin-json = "https://open-vsx.org/api/vscode/json/1.46.1/file/vscode.json-1.46.1.vsix";
vscode-json-language-features = "https://open-vsx.org/api/vscode/json-language-features/1.46.1/file/vscode.json-language-features-1.46.1.vsix";
vscode-builtin-markdown = "https://open-vsx.org/api/vscode/markdown/1.46.1/file/vscode.markdown-1.46.1.vsix";
@@ -129,7 +130,7 @@ let
Description=nixide service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
@@ -146,7 +147,7 @@ let
base_clean_file = pkgs.writeText "clean-nixide.service" ''
[Unit]
Description= nixide clean service
[Service]
Type=Oneshot
Restart=always
@@ -166,7 +167,7 @@ let
sed -i "s|PROJECT_FOLDER_PLACE_HOLDER|$PROJECT_FOLDER|g" $NIXIDE_SERVICE_NAME.service
sed -i "s|WORKING_DIRECTORY_PLACE_HOLDER|$WORKING_FOLDER|g" $NIXIDE_SERVICE_NAME.service
sed -i "s|PWD_PLACE_HOLDER|$PWD|g" $NIXIDE_SERVICE_NAME.service
cp -f ${base_clean_file} clean-$NIXIDE_SERVICE_NAME.service
sed -i "s|THEIA_IDE_APP_FOLDER_PLACE_HOLDER|$THEIA_IDE_APP_FOLDER|g" clean-$NIXIDE_SERVICE_NAME.service
sed -i "s|WORKING_DIRECTORY_PLACE_HOLDER|$WORKING_FOLDER|g" clean-$NIXIDE_SERVICE_NAME.service

View File

@@ -33,7 +33,7 @@ const CLEAN_RUN_ARGUMENT_NAME: &str = "clean-run";
const VERBOSE_ARGUMENT_NAME: &str = "verbose";
const IDE_ID_ARGUMENT_NAME: &str = "ide-id";
fn main() {
fn main() {
let start_ide_file_arg =Arg::with_name(START_FILE_ARGUMENT_NAME)
.short("s")
@@ -50,7 +50,7 @@ fn main() {
.default_value("{}")
.takes_value(true);
let matches =
let matches =
App::new("nixidectl")
.version("0.1.0")
.author("stubbfel")
@@ -59,11 +59,11 @@ fn main() {
.arg(&start_ide_file_arg)
.arg(&start_ide_arguments_args)
.arg(Arg::with_name(CLEAN_RUN_ARGUMENT_NAME)
.short("c")
.short("c")
.long("clean-run")
.help("clean app folder, before start runnnig"))
.arg(Arg::with_name(VERBOSE_ARGUMENT_NAME)
.short("v")
.short("v")
.long("verbose")
.help("verbose")))
.subcommand(SubCommand::with_name(STOP_SUBCOMMAND_NAME)
@@ -90,7 +90,7 @@ fn main() {
.help("the name of the ide serive")
.default_value("nixide")
.takes_value(true)
.global(true))
.global(true))
.subcommand(SubCommand::with_name(INSTALL_SUBCOMMAND_NAME)
.arg(&start_ide_file_arg)
.arg(&start_ide_arguments_args)
@@ -111,7 +111,7 @@ fn main() {
_ => "run_ide.sh"
};
let nix_expression = format!("with import <nixpkgs> {{}}; callPackage {} {}", file, args);
let nix_expression = format!("with import <nixpkgs> {{}}; callPackage {} {}", file, args);
let cmd = Command::new("nix-shell")
.stderr(Stdio::null())
//.stdout(Stdio::null())
@@ -123,7 +123,7 @@ fn main() {
.arg(run_script)
.spawn()
.expect("start ide command failed");
let out = cmd.stdout.ok_or_else(|| Error::new(ErrorKind::Other,"Could not capture standard output.")).unwrap();
let reader = BufReader::new(out);
let start_up_log = reader.lines()

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(())
}