Hi, I’m looking for a solution for a couple of days now.
I maybe too new to this topic, but I did not find a solution here yet.
I want to set up an openvscode-server as a systemd service in nixos, to provide a c/cpp project to students in a browser. But with the default method some environment variables are not set inside the running server and so my cmake of the project breaks at criterion (criterion.dev) I want to expose with this codeserver is not building.
I’ve built a nix file which provides a nix-shell in which, when started properly, the openvscode-server runs and all environment variables are set correctly.
Is there somehow a straight forward way to convert this into a systemd service?
Cheers Robert
{ pkgs ? import <nixpkgs> {} }:
let
download_plugins = [
{
url="https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/cpptools/1.20.0/vspackage?targetPlatform=linux-x64";
sha256="sha256-uRKjijhlkX5iYwSAqdOreEOK5feLKF+ymwYz74mf9wY=";
}
];
id_plugins = [
"franneck94.vscode-c-cpp-dev-extension-pack"
"shyykoserhiy.git-autoconfig"
"ms-vscode.cmake-tools"
];
vsix_files = pkgs.lib.lists.forEach download_plugins (x : pkgs.fetchurl x );
install_plugs = pkgs.writeShellScript "install_plugs.sh" ''
for zvsix in ${toString vsix_files}; do
echo installing ''${zvsic}
zcat -d ''${zvsix} > plug.vsix
openvscode-server --install-extension plug.vsix
rm plug.vsix
done
for extid in ${toString id_plugins}; do
echo installing ''${extid}
openvscode-server --install-extension ''${extid}
done
'';
start_server = pkgs.writeShellScript "start_server.sh" ''
${install_plugs} &
openvscode-server --host 0.0.0.0 --without-connection-token
'';
in
pkgs.mkShell {
packages = with pkgs; [ pstree coreutils busybox bashInteractive criterion.dev cmake gdb gcc gnumake git openvscode-server ];
shellHook = ''
echo run ${start_server}
'';
}