From ff705b9dd566b0a7668c13dc271aa091b458bc2a Mon Sep 17 00:00:00 2001 From: ZHAO Jin-Xiang Date: Sat, 8 Feb 2025 15:18:48 +0800 Subject: [PATCH] windsurf: init at 1.2.6 --- pkgs/applications/editors/vscode/generic.nix | 3 +- pkgs/by-name/wi/windsurf/info.json | 20 +++++ pkgs/by-name/wi/windsurf/package.nix | 57 +++++++++++++ pkgs/by-name/wi/windsurf/update/.gitignore | 2 + pkgs/by-name/wi/windsurf/update/package.json | 12 +++ pkgs/by-name/wi/windsurf/update/tsconfig.json | 9 ++ pkgs/by-name/wi/windsurf/update/update.mts | 82 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 + 8 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/wi/windsurf/info.json create mode 100644 pkgs/by-name/wi/windsurf/package.nix create mode 100644 pkgs/by-name/wi/windsurf/update/.gitignore create mode 100644 pkgs/by-name/wi/windsurf/update/package.json create mode 100644 pkgs/by-name/wi/windsurf/update/tsconfig.json create mode 100755 pkgs/by-name/wi/windsurf/update/update.mts diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index 0b5f20efd165..c5f0c0b51673 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -33,6 +33,7 @@ # Attributes inherit from specific versions version, + vscodeVersion ? version, src, meta, sourceRoot, @@ -303,7 +304,7 @@ stdenv.mkDerivation ( let vscodeRipgrep = if stdenv.hostPlatform.isDarwin then - if lib.versionAtLeast version "1.94.0" then + if lib.versionAtLeast vscodeVersion "1.94.0" then "Contents/Resources/app/node_modules/@vscode/ripgrep/bin/rg" else "Contents/Resources/app/node_modules.asar.unpacked/@vscode/ripgrep/bin/rg" diff --git a/pkgs/by-name/wi/windsurf/info.json b/pkgs/by-name/wi/windsurf/info.json new file mode 100644 index 000000000000..83356b1e12a7 --- /dev/null +++ b/pkgs/by-name/wi/windsurf/info.json @@ -0,0 +1,20 @@ +{ + "aarch64-darwin": { + "version": "1.2.6", + "vscodeVersion": "1.94.0", + "url": "https://windsurf-stable.codeiumdata.com/darwin-arm64/stable/d08b8ea13d580d24be204c76e5dd1651d7234cd2/Windsurf-darwin-arm64-1.2.6.zip", + "sha256": "b9a63785454003f7ccb3b6adebe232e24618247244b556ef61e9e974a4b77f65" + }, + "x86_64-darwin": { + "version": "1.2.6", + "vscodeVersion": "1.94.0", + "url": "https://windsurf-stable.codeiumdata.com/darwin-x64/stable/d08b8ea13d580d24be204c76e5dd1651d7234cd2/Windsurf-darwin-x64-1.2.6.zip", + "sha256": "4a4beae35117162b484521a64fc67cac044ced17a971553ab75ba8823b3cbb75" + }, + "x86_64-linux": { + "version": "1.2.6", + "vscodeVersion": "1.94.0", + "url": "https://windsurf-stable.codeiumdata.com/linux-x64/stable/d08b8ea13d580d24be204c76e5dd1651d7234cd2/Windsurf-linux-x64-1.2.6.tar.gz", + "sha256": "ad71eb02b9302d4cf1413c0a83763f45fe455e5be74ee9e1477bea2e85a02caa" + } +} diff --git a/pkgs/by-name/wi/windsurf/package.nix b/pkgs/by-name/wi/windsurf/package.nix new file mode 100644 index 000000000000..92cb26bffc61 --- /dev/null +++ b/pkgs/by-name/wi/windsurf/package.nix @@ -0,0 +1,57 @@ +{ + lib, + stdenv, + callPackage, + vscode-generic, + fetchurl, + nixosTests, + commandLineArgs ? "", + useVSCodeRipgrep ? stdenv.hostPlatform.isDarwin, +}: +let + info = + (lib.importJSON ./info.json)."${stdenv.hostPlatform.system}" + or (throw "windsurf: unsupported system ${stdenv.hostPlatform.system}"); +in +callPackage vscode-generic rec { + inherit commandLineArgs useVSCodeRipgrep; + + inherit (info) version vscodeVersion; + pname = "windsurf"; + + executableName = "windsurf"; + longName = "Windsurf"; + shortName = "windsurf"; + + sourceRoot = if stdenv.hostPlatform.isDarwin then "Windsurf.app" else "Windsurf"; + + src = fetchurl { inherit (info) url sha256; }; + + tests = nixosTests.vscodium; + + updateScript = ./update/update.mts; + + # Editing the `codium` binary (and shell scripts) within the app bundle causes the bundle's signature + # to be invalidated, which prevents launching starting with macOS Ventura, because VSCodium is notarized. + # See https://eclecticlight.co/2022/06/17/app-security-changes-coming-in-ventura/ for more information. + dontFixup = stdenv.hostPlatform.isDarwin; + + meta = { + description = "Agentic IDE powered by AI Flow paradigm"; + longDescription = '' + The first agentic IDE, and then some. + The Windsurf Editor is where the work of developers and AI truly flow together, allowing for a coding experience that feels like literal magic. + ''; + homepage = "https://codeium.com/windsurf"; + license = lib.licenses.unfree; + maintainers = with lib.maintainers; [ + xiaoxiangmoe + ]; + platforms = [ + "aarch64-darwin" + "x86_64-darwin" + "x86_64-linux" + ]; + sourceProvenance = [ lib.sourceTypes.binaryBytecode ]; + }; +} diff --git a/pkgs/by-name/wi/windsurf/update/.gitignore b/pkgs/by-name/wi/windsurf/update/.gitignore new file mode 100644 index 000000000000..d5f19d89b308 --- /dev/null +++ b/pkgs/by-name/wi/windsurf/update/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json diff --git a/pkgs/by-name/wi/windsurf/update/package.json b/pkgs/by-name/wi/windsurf/update/package.json new file mode 100644 index 000000000000..d61a0d4ec9f5 --- /dev/null +++ b/pkgs/by-name/wi/windsurf/update/package.json @@ -0,0 +1,12 @@ +{ + "name": "windsurf-scripts", + "version": "1.0.0", + "scripts": { + "update": "node update.mts" + }, + "dependencies": { + "@types/node": "^22.13.1", + "prettier": "^3.4.2", + "typescript": "^5.7.3" + } +} diff --git a/pkgs/by-name/wi/windsurf/update/tsconfig.json b/pkgs/by-name/wi/windsurf/update/tsconfig.json new file mode 100644 index 000000000000..347a07fb3e23 --- /dev/null +++ b/pkgs/by-name/wi/windsurf/update/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "module": "NodeNext", + "noEmit": true, + "strict": true + } +} diff --git a/pkgs/by-name/wi/windsurf/update/update.mts b/pkgs/by-name/wi/windsurf/update/update.mts new file mode 100755 index 000000000000..5db74e3b5346 --- /dev/null +++ b/pkgs/by-name/wi/windsurf/update/update.mts @@ -0,0 +1,82 @@ +#!/usr/bin/env nix-shell +/* +#!nix-shell -i node --pure --packages cacert nodejs_23 +*/ +import * as assert from "node:assert/strict"; +import * as fsPromises from "node:fs/promises"; +import * as path from "node:path"; +import * as process from "node:process"; + +const __dirname = import.meta.dirname; +const __filename = import.meta.filename; + +interface LatestInfo { + readonly url: string; + readonly sha256hash: string; + readonly windsurfVersion: string; + readonly productVersion: string; +} + +const platforms = ["aarch64-darwin", "x86_64-darwin", "x86_64-linux"] as const; +type Platform = (typeof platforms)[number]; +type InfoMap = Record< + Platform, + { + readonly version: string; + readonly vscodeVersion: string; + readonly url: string; + readonly sha256: string; + } +>; + +async function getInfo(targetSystem: "darwin-arm64" | "darwin-x64" | "linux-x64") { + const url = + `https://windsurf-stable.codeium.com/api/update/${targetSystem}/stable/latest` as const; + + const response = await fetch(url); + assert.ok(response.ok, `Failed to fetch ${url}`); + + const latestInfo: LatestInfo = JSON.parse(await response.text()); + assert.ok(latestInfo.sha256hash, "sha256hash is required"); + assert.ok(latestInfo.url, "url is required"); + assert.ok(latestInfo.windsurfVersion, "windsurfVersion is required"); + assert.ok(latestInfo.productVersion, "productVersion is required"); + return { + version: latestInfo.windsurfVersion, + vscodeVersion: latestInfo.productVersion, + url: latestInfo.url, + sha256: latestInfo.sha256hash, + }; +} + +async function main() { + const filePath = path.join(__dirname, "../info.json"); + const oldInfo = JSON.parse( + await fsPromises.readFile(filePath, { encoding: "utf-8" }), + ); + + const info: InfoMap = { + "aarch64-darwin": await getInfo("darwin-arm64"), + "x86_64-darwin": await getInfo("darwin-x64"), + "x86_64-linux": await getInfo("linux-x64"), + }; + if (JSON.stringify(oldInfo) === JSON.stringify(info)) { + console.log("[update] No updates found"); + return; + } + for (const platform of platforms) { + console.log( + `[update] Updating Windsurf ${platform} ${oldInfo[platform].version} -> ${info[platform].version}`, + ); + } + await fsPromises.writeFile( + filePath, + JSON.stringify(info, null, 2) + "\n", + "utf-8", + ); + console.log("[update] Updating Windsurf complete"); +} + +if (process.argv[1] === __filename) { + main(); +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 900b41006d34..dcacf936d9c1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15594,6 +15594,10 @@ with pkgs; vscodium-fhs = vscodium.fhs; vscodium-fhsWithPackages = vscodium.fhsWithPackages; + windsurf = callPackage ../by-name/wi/windsurf/package.nix { + vscode-generic = ../applications/editors/vscode/generic.nix; + }; + openvscode-server = callPackage ../servers/openvscode-server { nodejs = nodejs_18; inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Security;