From 4853879264376ae7d20dea2a7af58490f179bc7a Mon Sep 17 00:00:00 2001 From: Flameopathic <64027365+Flameopathic@users.noreply.github.com> Date: Fri, 7 Mar 2025 03:18:46 -0500 Subject: [PATCH] vscode: support arbitrary profiles (#914) vscode: support arbitrary profiles The VSCode theme is no longer only applied to any profiles by default. Closes: https://github.com/danth/stylix/issues/908 Link: https://github.com/danth/stylix/pull/914 Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com> --- modules/vscode/hm.nix | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/modules/vscode/hm.nix b/modules/vscode/hm.nix index b7269093..99049742 100644 --- a/modules/vscode/hm.nix +++ b/modules/vscode/hm.nix @@ -26,15 +26,23 @@ let ln -s ${themeFile} "$out/share/vscode/extensions/$vscodeExtUniqueId/themes/stylix.json" ''; + cfg = config.stylix.targets.vscode; + in { - options.stylix.targets.vscode.enable = - config.lib.stylix.mkEnableTarget "VSCode" true; + options.stylix.targets.vscode = { + enable = config.lib.stylix.mkEnableTarget "VSCode" true; + profileNames = lib.mkOption { + description = "The VSCode profile names to apply styling on."; + type = lib.types.listOf lib.types.str; + default = [ ]; + }; + }; - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.vscode.enable) - { - programs.vscode.profiles.default = { + config = lib.mkIf (config.stylix.enable && cfg.enable) { + programs.vscode.profiles = lib.mkMerge ( + map (profileName: { + ${profileName} = { extensions = [ themeExtension ]; userSettings = { "workbench.colorTheme" = "Stylix"; @@ -62,5 +70,14 @@ in "screencastMode.fontSize" = sizes.terminal * 4.0 / 3.0 * 56.0 / 14.0; }; }; - }; + }) cfg.profileNames + ); + warnings = + lib.optional + ( + config.programs.vscode.enable + && config.stylix.targets.vscode.profileNames == [ ] + ) + ''stylix: vscode: `config.stylix.targets.vscode.profileNames` is not set. Declare profile names with 'config.stylix.targets.vscode.profileNames = [ "" ];'.''; + }; }