From b2ff7ceff25d3e7cb0f6e18ee84d7921cee03d7d Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 13 Mar 2022 18:16:34 +1100 Subject: nixos/tests: Test that Remote SSH can patch Node --- pkgs/applications/editors/vscode/vscode.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pkgs/applications/editors/vscode/vscode.nix') diff --git a/pkgs/applications/editors/vscode/vscode.nix b/pkgs/applications/editors/vscode/vscode.nix index fb1dd7596ecec..333bf848ada55 100644 --- a/pkgs/applications/editors/vscode/vscode.nix +++ b/pkgs/applications/editors/vscode/vscode.nix @@ -1,4 +1,8 @@ -{ stdenv, lib, callPackage, fetchurl +{ stdenv +, lib +, callPackage +, fetchurl +, nixosTests , isInsiders ? false , commandLineArgs ? "" , useVSCodeRipgrep ? stdenv.isDarwin @@ -48,6 +52,8 @@ in sourceRoot = ""; + tests = { inherit (nixosTests) vscode-remote-ssh; }; + updateScript = ./update-vscode.sh; # Editing the `code` binary within the app bundle causes the bundle's signature -- cgit 1.4.1 From fbf5e75aa21f45420853738b0a1910155fc1f696 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 13 Mar 2022 20:38:22 +1100 Subject: vscode: Update remote-ssh commit hash with updater --- pkgs/applications/editors/vscode/update-vscode.sh | 24 +++++++++++++++++++++-- pkgs/applications/editors/vscode/vscode.nix | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'pkgs/applications/editors/vscode/vscode.nix') diff --git a/pkgs/applications/editors/vscode/update-vscode.sh b/pkgs/applications/editors/vscode/update-vscode.sh index 67ec7a21b3461..b857d29224e4d 100755 --- a/pkgs/applications/editors/vscode/update-vscode.sh +++ b/pkgs/applications/editors/vscode/update-vscode.sh @@ -14,14 +14,34 @@ if [ ! -f "$ROOT/vscode.nix" ]; then 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/version = \".*\"/version = \"${VSCODE_VER}\"/" "$ROOT/vscode.nix" +TEMP_FOLDER=$(mktemp -d) + VSCODE_X64_LINUX_URL="https://update.code.visualstudio.com/${VSCODE_VER}/linux-x64/stable" -VSCODE_X64_LINUX_SHA256=$(nix-prefetch-url ${VSCODE_X64_LINUX_URL}) -sed -i "s/x86_64-linux = \".\{52\}\"/x86_64-linux = \"${VSCODE_X64_LINUX_SHA256}\"/" "$ROOT/vscode.nix" + +# Split output by newlines into Bash array +readarray -t VSCODE_X64_LINUX <<< $(nix-prefetch-url --print-path ${VSCODE_X64_LINUX_URL}) + +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 +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" + +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" VSCODE_X64_DARWIN_URL="https://update.code.visualstudio.com/${VSCODE_VER}/darwin/stable" VSCODE_X64_DARWIN_SHA256=$(nix-prefetch-url ${VSCODE_X64_DARWIN_URL}) diff --git a/pkgs/applications/editors/vscode/vscode.nix b/pkgs/applications/editors/vscode/vscode.nix index 333bf848ada55..519a4b6f19424 100644 --- a/pkgs/applications/editors/vscode/vscode.nix +++ b/pkgs/applications/editors/vscode/vscode.nix @@ -77,7 +77,7 @@ in homepage = "https://code.visualstudio.com/"; downloadPage = "https://code.visualstudio.com/Updates"; license = licenses.unfree; - maintainers = with maintainers; [ eadwu synthetica maxeaubrey bobby285271 ]; + maintainers = with maintainers; [ eadwu synthetica maxeaubrey bobby285271 Enzime ]; platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" "armv7l-linux" ]; }; } -- cgit 1.4.1 From 8bf8b8fd68b644f3c1ab3a52464173212da2dfaf Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Thu, 1 Jun 2023 01:09:50 +1000 Subject: vscode: move rev and vscodeServer to derivation --- nixos/tests/vscode-remote-ssh.nix | 29 ++++++----------------- pkgs/applications/editors/vscode/generic.nix | 4 ++++ pkgs/applications/editors/vscode/update-vscode.sh | 13 +++------- pkgs/applications/editors/vscode/vscode.nix | 14 +++++++++++ 4 files changed, 28 insertions(+), 32 deletions(-) (limited to 'pkgs/applications/editors/vscode/vscode.nix') diff --git a/nixos/tests/vscode-remote-ssh.nix b/nixos/tests/vscode-remote-ssh.nix index 87fdc0bd504d0..de7cc6badc9a2 100644 --- a/nixos/tests/vscode-remote-ssh.nix +++ b/nixos/tests/vscode-remote-ssh.nix @@ -11,22 +11,7 @@ import ./make-test-python.nix ({ lib, ... }@args: let 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 ]; @@ -61,12 +46,12 @@ in { 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" @@ -80,7 +65,7 @@ in { 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") @@ -108,7 +93,7 @@ in { 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" @@ -116,8 +101,8 @@ in { 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") diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index 7b7007910a5c6..6d1c20c855415 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -13,6 +13,8 @@ , 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 @@ -30,6 +32,8 @@ let inherit executableName longName tests updateScript; fhs = fhs {}; fhsWithPackages = f: fhs { additionalPkgs = f; }; + } // lib.optionalAttrs (vscodeServer != null) { + inherit rev vscodeServer; }; desktopItem = makeDesktopItem { diff --git a/pkgs/applications/editors/vscode/update-vscode.sh b/pkgs/applications/editors/vscode/update-vscode.sh index b857d29224e4d..d1df522f40247 100755 --- a/pkgs/applications/editors/vscode/update-vscode.sh +++ b/pkgs/applications/editors/vscode/update-vscode.sh @@ -14,13 +14,6 @@ if [ ! -f "$ROOT/vscode.nix" ]; then 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) @@ -35,13 +28,13 @@ readarray -t VSCODE_X64_LINUX <<< $(nix-prefetch-url --print-path ${VSCODE_X64_L 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}) diff --git a/pkgs/applications/editors/vscode/vscode.nix b/pkgs/applications/editors/vscode/vscode.nix index 519a4b6f19424..b281099a689e1 100644 --- a/pkgs/applications/editors/vscode/vscode.nix +++ b/pkgs/applications/editors/vscode/vscode.nix @@ -3,6 +3,7 @@ , callPackage , fetchurl , nixosTests +, srcOnly , isInsiders ? false , commandLineArgs ? "" , useVSCodeRipgrep ? stdenv.isDarwin @@ -36,6 +37,9 @@ in 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"; @@ -52,6 +56,16 @@ in 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; }; updateScript = ./update-vscode.sh; -- cgit 1.4.1