From 5c92c0e0acb9dea484eec0c217f77ddcccdf3f91 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Tue, 30 Jan 2024 21:41:30 +0800 Subject: [PATCH] feat: add vscode again, to get the best experience of copilot chat --- home/linux/desktop/base/xdg.nix | 15 ++++++++-- .../desktop/hyprland/values/wayland-apps.nix | 29 +++++++++++++++++++ home/linux/desktop/i3/values/x11-apps.nix | 13 +++++++-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/home/linux/desktop/base/xdg.nix b/home/linux/desktop/base/xdg.nix index 4f305e8a..4292880c 100644 --- a/home/linux/desktop/base/xdg.nix +++ b/home/linux/desktop/base/xdg.nix @@ -30,14 +30,17 @@ # ls /etc/profiles/per-user/ryan/share/applications/ mimeApps = { enable = true; + # let `xdg-open` to open the url with the correct application. defaultApplications = let browser = ["firefox.desktop"]; + editor = ["nvim.desktop" "Helix.desktop" "code.desktop" "code-insiders.desktop"]; in { "application/json" = browser; "application/pdf" = browser; # TODO: pdf viewer "text/html" = browser; "text/xml" = browser; + "text/plain" = editor; "application/xml" = browser; "application/xhtml+xml" = browser; "application/xhtml_xml" = browser; @@ -48,12 +51,18 @@ "application/x-extension-shtml" = browser; "application/x-extension-xht" = browser; "application/x-extension-xhtml" = browser; + "application/x-wine-extension-ini" = editor; - "x-scheme-handler/about" = browser; - "x-scheme-handler/ftp" = browser; + # define default applications for some url schemes. + "x-scheme-handler/about" = browser; # open `about:` url with `browser` + "x-scheme-handler/ftp" = browser; # open `ftp:` url with `browser` "x-scheme-handler/http" = browser; "x-scheme-handler/https" = browser; - "x-scheme-handler/unknown" = browser; + # https://github.com/microsoft/vscode/issues/146408 + "x-scheme-handler/vscode" = ["code-url-handler.desktop"]; # open `vscode://` url with `code-url-handler.desktop` + "x-scheme-handler/vscode-insiders" = ["code-insiders-url-handler.desktop"]; # open `vscode-insiders://` url with `code-insiders-url-handler.desktop` + # all other unknown schemes will be opened by this default application. + # "x-scheme-handler/unknown" = editor; "x-scheme-handler/discord" = ["discord.desktop"]; "x-scheme-handler/tg" = ["org.telegram.desktop.desktop "]; diff --git a/home/linux/desktop/hyprland/values/wayland-apps.nix b/home/linux/desktop/hyprland/values/wayland-apps.nix index b9cc9919..b24963c9 100644 --- a/home/linux/desktop/hyprland/values/wayland-apps.nix +++ b/home/linux/desktop/hyprland/values/wayland-apps.nix @@ -58,5 +58,34 @@ enableGnomeExtensions = false; package = pkgs.firefox-wayland; # firefox with wayland support }; + + vscode = { + enable = true; + # let vscode sync and update its configuration & extensions across devices, using github account. + userSettings = {}; + package = + (pkgs.vscode.override + { + isInsiders = true; + commandLineArgs = [ + # "--disable-gpu" + # make it use text-input-v1, which works for kwin 5.27 and weston + "--enable-features=UseOzonePlatform" + "--ozone-platform=wayland" + "--enable-wayland-ime" + # TODO: fix https://github.com/microsoft/vscode/issues/187436 + # still not works... + "--password-store=gnome" # use gnome-keyring as password store + ]; + }) + .overrideAttrs (oldAttrs: rec { + # Use VSCode Insiders to fix crash: https://github.com/NixOS/nixpkgs/issues/246509 + src = builtins.fetchTarball { + url = "https://update.code.visualstudio.com/latest/linux-x64/insider"; + sha256 = "0k2sh7rb6mrx9d6bkk2744ry4g17d13xpnhcisk4akl4x7dn6a83"; + }; + version = "latest"; + }); + }; }; } diff --git a/home/linux/desktop/i3/values/x11-apps.nix b/home/linux/desktop/i3/values/x11-apps.nix index 4ea61f7a..58652429 100644 --- a/home/linux/desktop/i3/values/x11-apps.nix +++ b/home/linux/desktop/i3/values/x11-apps.nix @@ -1,9 +1,12 @@ -{pkgs, ...}: { +{ + pkgs, + pkgs-unstable, + ... +}: { home.packages = with pkgs; [ firefox ]; - # TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it. programs = { # source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix google-chrome = { @@ -16,5 +19,11 @@ # commandLineArgs = [ # ]; }; + vscode = { + enable = true; + package = pkgs-unstable.vscode; + # let vscode sync and update its configuration & extensions across devices, using github account. + # userSettings = {}; + }; }; }