init
This commit is contained in:
184
.nixide/start-ide.nix
Normal file
184
.nixide/start-ide.nix
Normal file
@@ -0,0 +1,184 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
listenAddress ? "0.0.0.0",
|
||||
listenPort ? 3000,
|
||||
theiaideAppFolder ? "_theiaideApp",
|
||||
projectFolder ? "$PWD",
|
||||
workingFolder ? "$PWD"
|
||||
}:
|
||||
|
||||
let
|
||||
theiaideBuildDependencies = [
|
||||
pkgs.nano
|
||||
pkgs.curl
|
||||
pkgs.yarn
|
||||
pkgs.nodejs-10_x
|
||||
pkgs.python27Full
|
||||
pkgs.git
|
||||
pkgs.wget
|
||||
pkgs.lzma
|
||||
pkgs.gcc
|
||||
pkgs.gnumake
|
||||
pkgs.gccStdenv
|
||||
pkgs.binutils
|
||||
pkgs.gnupg
|
||||
];
|
||||
|
||||
projectDependencies = [
|
||||
pkgs.rustc
|
||||
pkgs.rls
|
||||
pkgs.cargo
|
||||
pkgs.rustracer
|
||||
pkgs.clippy
|
||||
pkgs.rustfmt
|
||||
pkgs.rustup
|
||||
];
|
||||
|
||||
theiaidePackageConfig = {
|
||||
private= true;
|
||||
theia.frontend.config.applicationName = "DevelNixos";
|
||||
dependencies = {
|
||||
"@theia/callhierarchy" = "latest";
|
||||
"@theia/console" = "latest";
|
||||
"@theia/core" = "latest";
|
||||
"@theia/editor" = "latest";
|
||||
"@theia/editor-preview" = "latest";
|
||||
"@theia/file-search" = "latest";
|
||||
"@theia/filesystem" = "latest";
|
||||
"@theia/git" = "latest";
|
||||
"@theia/json" = "latest";
|
||||
"@theia/keymaps" = "latest";
|
||||
"@theia/languages" = "latest";
|
||||
"@theia/markers" = "latest";
|
||||
"@theia/messages" = "latest";
|
||||
"@theia/metrics" = "latest";
|
||||
"@theia/mini-browser" = "latest";
|
||||
"@theia/monaco" = "latest";
|
||||
"@theia/navigator" = "latest";
|
||||
"@theia/outline-view" = "latest";
|
||||
"@theia/output" = "latest";
|
||||
"@theia/plugin" = "latest";
|
||||
"@theia/plugin-ext" = "latest";
|
||||
"@theia/plugin-ext-vscode" = "latest";
|
||||
"@theia/preferences" = "latest";
|
||||
"@theia/preview" = "latest";
|
||||
"@theia/process" = "latest";
|
||||
"@theia/rust" = "latest";
|
||||
"@theia/scm" = "latest";
|
||||
"@theia/search-in-workspace" = "latest";
|
||||
"@theia/task" = "latest";
|
||||
"@theia/terminal" = "latest";
|
||||
"@theia/userstorage" = "latest";
|
||||
"@theia/variable-resolver" = "latest";
|
||||
"@theia/vsx-registry" = "latest";
|
||||
"@theia/workspace" = "latest";
|
||||
};
|
||||
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";
|
||||
vscode-builtin-markdown-language-features = "https://open-vsx.org/api/vscode/markdown-language-features/1.46.1/file/vscode.markdown-language-features-1.46.1.vsix";
|
||||
vscode-builtin-merge-conflicts = "https://open-vsx.org/api/vscode/merge-conflict/1.46.1/file/vscode.merge-conflict-1.46.1.vsix";
|
||||
vscode-builtin-shellscript = "https://open-vsx.org/api/vscode/shellscript/1.46.1/file/vscode.shellscript-1.46.1.vsix";
|
||||
vscode-builtin-xml = "https://open-vsx.org/api/vscode/xml/1.46.1/file/vscode.xml-1.46.1.vsix";
|
||||
vscode-builtin-yaml = "https://open-vsx.org/api/vscode/yaml/1.46.1/file/vscode.yaml-1.46.1.vsix";
|
||||
vscode-editorconfig = "https://open-vsx.org/api/EditorConfig/EditorConfig/0.15.1/file/EditorConfig.EditorConfig-0.15.1.vsix";
|
||||
vscode-githistory = "https://open-vsx.org/api/donjayamanne/githistory/0.6.6/file/donjayamanne.githistory-0.6.6.vsix";
|
||||
vscode-gitlens = "https://open-vsx.org/api/eamodio/gitlens/10.2.1/file/eamodio.gitlens-10.2.1.vsix";
|
||||
vscode-shellcheck= "https://open-vsx.org/api/timonwong/shellcheck/0.9.0/file/timonwong.shellcheck-0.9.0.vsix";
|
||||
vscode-rust = "https://open-vsx.org/api/vscode/rust/1.46.1/file/vscode.rust-1.46.1.vsix";
|
||||
formulahendry-code-runner = "https://open-vsx.org/api/formulahendry/code-runner/0.10.0/file/formulahendry.code-runner-0.10.0.vsix";
|
||||
rust-lang-rust = "https://open-vsx.org/api/rust-lang/rust/0.7.8/file/rust-lang.rust-0.7.8.vsix";
|
||||
# swellaby-vscode-rust-test-adapter = "https://open-vsx.org/api/Swellaby/vscode-rust-test-adapter/0.11.0/file/Swellaby.vscode-rust-test-adapter-0.11.0.vsix";
|
||||
serayuzgur-crates = "https://open-vsx.org/api/serayuzgur/crates/0.5.0/file/serayuzgur.crates-0.5.0.vsix";
|
||||
belfz-search-crates-io = "https://open-vsx.org/api/belfz/search-crates-io/1.2.1/file/belfz.search-crates-io-1.2.1.vsix";
|
||||
};
|
||||
devDependencies = {
|
||||
"@theia/cli" = "latest";
|
||||
};
|
||||
resolutions ={};
|
||||
theiaPluginsDir = "plugins";
|
||||
scripts = {
|
||||
prepare = "yarn run clean && yarn build && yarn run download:plugin";
|
||||
clean= "theia clean";
|
||||
build= "theia build";
|
||||
start= "theia start --plugins=local-dir:plugins";
|
||||
"download:plugin" = "theia download:plugins";
|
||||
};
|
||||
};
|
||||
|
||||
theiaidePackageFile = pkgs.writeText "package.json" (builtins.toJSON theiaidePackageConfig);
|
||||
|
||||
run_ide_script = pkgs.writeShellScriptBin "run_ide.sh" ''
|
||||
mkdir -p $THEIA_IDE_APP_FOLDER && \
|
||||
rm -f $THEIA_IDE_APP_FOLDER/package.json && \
|
||||
ln -s ${theiaidePackageFile} $THEIA_IDE_APP_FOLDER/package.json && \
|
||||
cd $THEIA_IDE_APP_FOLDER && \
|
||||
yarn && \
|
||||
yarn start $PROJECT_FOLDER --hostname ${listenAddress} --port ${toString listenPort}
|
||||
'';
|
||||
|
||||
clean_run_ide_script = pkgs.writeShellScriptBin "clean_run_ide.sh" ''
|
||||
rm -rf $THEIA_IDE_APP_FOLDER && \
|
||||
${run_ide_script}/bin/run_ide.sh
|
||||
'';
|
||||
|
||||
base_service_file = pkgs.writeText "nixide.service" ''
|
||||
[Unit]
|
||||
Description=nixide service
|
||||
After=network.target
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
Environment=THEIA_IDE_APP_FOLDER=THEIA_IDE_APP_FOLDER_PLACE_HOLDER
|
||||
Environment=PROJECT_FOLDER=PROJECT_FOLDER_PLACE_HOLDER
|
||||
WorkingDirectory=WORKING_DIRECTORY_PLACE_HOLDER
|
||||
ExecStart=/usr/bin/nix-shell --expr 'with import <nixpkgs> {}; callPackage PWD_PLACE_HOLDER/start-ide.nix {listenAddress = "${listenAddress}"; listenPort = ${toString listenPort}; theiaideAppFolder = "${theiaideAppFolder}"; projectFolder = "${projectFolder}";}' --pure --run ${run_ide_script}/bin/run_ide.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
'';
|
||||
|
||||
base_clean_file = pkgs.writeText "clean-nixide.service" ''
|
||||
[Unit]
|
||||
Description= nixide clean service
|
||||
|
||||
[Service]
|
||||
Type=Oneshot
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
Environment=THEIA_IDE_APP_FOLDER=THEIA_IDE_APP_FOLDER_PLACE_HOLDER
|
||||
WorkingDirectory=WORKING_DIRECTORY_PLACE_HOLDER
|
||||
ExecStart=rm -rf $THEIA_IDE_APP_FOLDER
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
'';
|
||||
|
||||
create_service_file = pkgs.writeShellScriptBin "create_service_file.sh" ''
|
||||
export NIXIDE_SERVICE_NAME=''${1:-nixide}
|
||||
cp -f ${base_service_file} $NIXIDE_SERVICE_NAME.service
|
||||
sed -i "s|THEIA_IDE_APP_FOLDER_PLACE_HOLDER|$THEIA_IDE_APP_FOLDER|g" $NIXIDE_SERVICE_NAME.service
|
||||
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
|
||||
'';
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "dev-shell";
|
||||
buildInputs = theiaideBuildDependencies ++ projectDependencies ++ [run_ide_script clean_run_ide_script create_service_file] ;
|
||||
shellHook =
|
||||
''
|
||||
export THEIA_IDE_APP_FOLDER=$(realpath ${theiaideAppFolder})
|
||||
export PROJECT_FOLDER=$(realpath ${projectFolder})
|
||||
export WORKING_FOLDER=$(realpath ${workingFolder})
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user