From d2111cc64516f31c1e72af4a67752deee06845c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 27 May 2023 12:00:08 +0200 Subject: [PATCH] feat(code)!: improve interface --- modules/programs/code.nix | 66 ++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/modules/programs/code.nix b/modules/programs/code.nix index 93cda16..f2a2955 100644 --- a/modules/programs/code.nix +++ b/modules/programs/code.nix @@ -9,21 +9,57 @@ let cfg = config.my.programs.code; in { - options.my.programs.code.enable = mkEnableOption "code"; - - config = mkIf cfg.enable { - home-manager.users.moritz = { - programs.vscode = { - enable = true; - package = pkgs.vscode-fhsWithPackages (ps: with ps; [ git ]); - extensions = with pkgs.vscode-extensions; [ - bbenoist.nix - dracula-theme.theme-dracula - esbenp.prettier-vscode - pkief.material-icon-theme - vscodevim.vim - ]; - }; + options.my.programs.code = { + enable = mkEnableOption "code"; + package = mkOption { + type = types.package; + default = pkgs.vscode; + }; + extensions = mkOption { + type = types.listOf types.package; + default = with pkgs.vscode-extensions; [ + bbenoist.nix + vscodevim.vim + ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ + { + name = "copilot-nightly"; + publisher = "GitHub"; + version = "1.86.118"; + sha256 = "04nspnmd5cfnv3m9igww6h6la6pvhdqzqmdnbm1znapxqiw2m927"; + } + { + name = "copilot-chat"; + publisher = "GitHub"; + version = "0.1.2023052602"; + sha256 = "0anlzzs4g7c9mmw7yxy5bgjcs0niwa3bswgvhwspf5fh8bbq5n44"; + } + ]; + }; + wayland = mkOption { + type = types.bool; + default = true; }; }; + + config = mkIf cfg.enable { + environment.systemPackages = + let + withExtensions = pkgs.vscode-with-extensions.override { + vscode = cfg.package; + vscodeExtensions = cfg.extensions; + }; + maybeExtensions = if cfg.extensions == [ ] then cfg.package else withExtensions; + withWayland = pkgs.symlinkJoin { + name = "${maybeExtensions.name}-wayland"; + paths = [ maybeExtensions ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/code* \ + --set NIXOS_OZONE_WL 1 + ''; + }; + final = if cfg.wayland then withWayland else maybeExtensions; + in + [ final ]; + }; }