vscode: move rev and vscodeServer to derivation

Changed files
+28 -32
nixos
pkgs
applications
+7 -22
nixos/tests/vscode-remote-ssh.nix
···
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
-
# Every VS Code server build corresponds to a specific commit of VS Code, so we
-
# want this to match the commit of VS Code in Nixpkgs.
-
# e.g. git rev-parse 1.77.0
-
rev = "b3e4e68a0bc097f0ae7907b217c1119af9e03435";
-
shortRev = builtins.substring 0 8 rev;
-
-
# Our tests run without networking so the remote-ssh extension will always fail to
-
# download the VSCode server so we can copy it onto the server ourselves.
-
vscode-server = pkgs.srcOnly {
-
name = "vscode-server-${shortRev}";
-
src = pkgs.fetchurl {
-
name = "vscode-server-${shortRev}.tar.gz";
-
url = "https://update.code.visualstudio.com/commit:${rev}/server-linux-x64/stable";
-
sha256 = "1gpsxlv4p3v3kh7b7b2i1lvm5g30xrq1vb7csqwhs4zjlbwfhdb2";
-
};
-
};
+
inherit (pkgs.vscode.passthru) rev vscodeServer;
in {
name = "vscode-remote-ssh";
meta.maintainers = with lib.maintainers; [ Enzime ];
···
testScript = let
jq = "${pkgs.jq}/bin/jq";
-
ssh-config = builtins.toFile "ssh.conf" ''
+
sshConfig = builtins.toFile "ssh.conf" ''
UserKnownHostsFile=/dev/null
StrictHostKeyChecking=no
'';
-
vscode-config = builtins.toFile "settings.json" ''
+
vscodeConfig = builtins.toFile "settings.json" ''
{
"window.zoomLevel": 1,
"security.workspace.trust.startupPrompt": "always"
···
server.succeed("rm -r ~/.vscode-server")
server.succeed("mkdir -p ~/.vscode-server/bin")
-
server.succeed("cp -r ${vscode-server} ~/.vscode-server/bin/${rev}")
+
server.succeed("cp -r ${vscodeServer} ~/.vscode-server/bin/${rev}")
client.succeed("sudo -u alice code --remote=ssh-remote+root@server /root")
client.wait_for_window("Visual Studio Code")
···
server.wait_for_open_port(22)
VSCODE_COMMIT = server.execute("${jq} -r .commit ${pkgs.vscode}/lib/vscode/resources/app/product.json")[1].rstrip()
-
SERVER_COMMIT = server.execute("${jq} -r .commit ${vscode-server}/product.json")[1].rstrip()
+
SERVER_COMMIT = server.execute("${jq} -r .commit ${vscodeServer}/product.json")[1].rstrip()
print(f"{VSCODE_COMMIT=} {SERVER_COMMIT=}")
assert VSCODE_COMMIT == SERVER_COMMIT, "VSCODE_COMMIT and SERVER_COMMIT do not match"
···
client.wait_until_succeeds("ping -c1 server")
client.succeed("sudo -u alice mkdir ~alice/.ssh")
client.succeed("sudo -u alice install -Dm 600 ${snakeOilPrivateKey} ~alice/.ssh/id_ecdsa")
-
client.succeed("sudo -u alice install ${ssh-config} ~alice/.ssh/config")
-
client.succeed("sudo -u alice install -Dm 644 ${vscode-config} ~alice/.config/Code/User/settings.json")
+
client.succeed("sudo -u alice install ${sshConfig} ~alice/.ssh/config")
+
client.succeed("sudo -u alice install -Dm 644 ${vscodeConfig} ~alice/.config/Code/User/settings.json")
client.wait_for_x()
client.wait_for_file("~alice/.Xauthority")
+4
pkgs/applications/editors/vscode/generic.nix
···
, version, src, meta, sourceRoot, commandLineArgs
, executableName, longName, shortName, pname, updateScript
, dontFixup ? false
+
, rev ? null, vscodeServer ? null
+
# sourceExecutableName is the name of the binary in the source archive, over
# which we have no control
, sourceExecutableName ? executableName
···
inherit executableName longName tests updateScript;
fhs = fhs {};
fhsWithPackages = f: fhs { additionalPkgs = f; };
+
} // lib.optionalAttrs (vscodeServer != null) {
+
inherit rev vscodeServer;
};
desktopItem = makeDesktopItem {
+3 -10
pkgs/applications/editors/vscode/update-vscode.sh
···
exit 1
fi
-
NIXPKGS_ROOT="$(git rev-parse --show-toplevel)"
-
-
if [ ! -f "$NIXPKGS_ROOT/nixos/tests/vscode-remote-ssh.nix" ]; then
-
echo "ERROR: cannot find nixos/tests/vscode-remote-ssh.nix"
-
exit 1
-
fi
-
# VSCode
VSCODE_VER=$(curl --fail --silent https://api.github.com/repos/Microsoft/vscode/releases/latest | jq --raw-output .tag_name)
···
sed -i "s/x86_64-linux = \".\{52\}\"/x86_64-linux = \"${VSCODE_X64_LINUX[0]}\"/" "$ROOT/vscode.nix"
-
tar xf $VSCODE_X64_LINUX[1] -C $TEMP_FOLDER
+
tar xf ${VSCODE_X64_LINUX[1]} -C $TEMP_FOLDER
VSCODE_COMMIT=$(jq --raw-output .commit $TEMP_FOLDER/VSCode-linux-x64/resources/app/product.json)
-
sed -i "s/rev = \".\{40\}\"/rev = \"${VSCODE_COMMIT}\"/" "$NIXPKGS_ROOT/nixos/tests/vscode-remote-ssh.nix"
+
sed -i "s/rev = \".\{40\}\"/rev = \"${VSCODE_COMMIT}\"/" "$ROOT/vscode.nix"
SERVER_X64_LINUX_URL="https://update.code.visualstudio.com/commit:${VSCODE_COMMIT}/server-linux-x64/stable"
SERVER_X64_LINUX_SHA256=$(nix-prefetch-url ${SERVER_X64_LINUX_URL})
-
sed -i "s/sha256 = \".\{51,52\}\"/sha256 = \"${SERVER_X64_LINUX_SHA256}\"/" "$NIXPKGS_ROOT/nixos/tests/vscode-remote-ssh.nix"
+
sed -i "s/sha256 = \".\{51,52\}\"/sha256 = \"${SERVER_X64_LINUX_SHA256}\"/" "$ROOT/vscode.nix"
VSCODE_X64_DARWIN_URL="https://update.code.visualstudio.com/${VSCODE_VER}/darwin/stable"
VSCODE_X64_DARWIN_SHA256=$(nix-prefetch-url ${VSCODE_X64_DARWIN_URL})
+14
pkgs/applications/editors/vscode/vscode.nix
···
, callPackage
, fetchurl
, nixosTests
+
, srcOnly
, isInsiders ? false
, commandLineArgs ? ""
, useVSCodeRipgrep ? stdenv.isDarwin
···
version = "1.79.0";
pname = "vscode";
+
# This is used for VS Code - Remote SSH test
+
rev = "b380da4ef1ee00e224a15c1d4d9793e27c2b6302";
+
executableName = "code" + lib.optionalString isInsiders "-insiders";
longName = "Visual Studio Code" + lib.optionalString isInsiders " - Insiders";
shortName = "Code" + lib.optionalString isInsiders " - Insiders";
···
tests = {};
sourceRoot = "";
+
+
# As tests run without networking, we need to download this for the Remote SSH server
+
vscodeServer = srcOnly {
+
name = "vscode-server-${rev}.tar.gz";
+
src = fetchurl {
+
name = "vscode-server-${rev}.tar.gz";
+
url = "https://update.code.visualstudio.com/commit:${rev}/server-linux-x64/stable";
+
sha256 = "0732wpl4fjknhn423k23zrcqz9psjj1iy8lqa0fc8970n1m7i58b";
+
};
+
};
tests = { inherit (nixosTests) vscode-remote-ssh; };