11.stylix/modules/vscode/hm.nix
Jaanonim cbe42e21ee
treewide: rename wpaperd and vscode options (#905)
Resolve the following warnings:

    - The option `programs.wpaperd.settings' defined in
      `/nix/store/<HASH>-source/modules/wpaperd/hm.nix' has been renamed
      to `services.wpaperd.settings'.

    - The option `programs.vscode.extensions' defined in
      `/nix/store/<HASH>-source/modules/vscode/hm.nix' has been renamed
      to `programs.vscode.profiles.default.extensions'.

    - The option `programs.vscode.userSettings' defined in
      `/nix/store/<HASH>-source/modules/vscode/hm.nix' has been renamed
      to `programs.vscode.profiles.default.userSettings'.


The VSCode theme is now only applied to the 'default' profile.

Closes: https://github.com/danth/stylix/issues/903
Link: https://github.com/danth/stylix/pull/905

Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
2025-02-24 16:43:41 +01:00

66 lines
2.3 KiB
Nix

{
pkgs,
config,
lib,
...
}:
with config.stylix.fonts;
let
themeFile = config.lib.stylix.colors {
template = ./template.mustache;
extension = ".json";
};
themeExtension =
pkgs.runCommandLocal "stylix-vscode"
{
vscodeExtUniqueId = "stylix.stylix";
vscodeExtPublisher = "stylix";
version = "0.0.0";
}
''
mkdir -p "$out/share/vscode/extensions/$vscodeExtUniqueId/themes"
ln -s ${./package.json} "$out/share/vscode/extensions/$vscodeExtUniqueId/package.json"
ln -s ${themeFile} "$out/share/vscode/extensions/$vscodeExtUniqueId/themes/stylix.json"
'';
in
{
options.stylix.targets.vscode.enable =
config.lib.stylix.mkEnableTarget "VSCode" true;
config =
lib.mkIf (config.stylix.enable && config.stylix.targets.vscode.enable)
{
programs.vscode.profiles.default = {
extensions = [ themeExtension ];
userSettings = {
"workbench.colorTheme" = "Stylix";
"editor.fontFamily" = monospace.name;
"editor.inlayHints.fontFamily" = monospace.name;
"editor.inlineSuggest.fontFamily" = monospace.name;
"scm.inputFontFamily" = monospace.name;
"debug.console.fontFamily" = monospace.name;
"markdown.preview.fontFamily" = sansSerif.name;
"chat.editor.fontFamily" = monospace.name;
# 4/3 factor used for pt to px;
"editor.fontSize" = sizes.terminal * 4.0 / 3.0;
"debug.console.fontSize" = sizes.terminal * 4.0 / 3.0;
"markdown.preview.fontSize" = sizes.terminal * 4.0 / 3.0;
"terminal.integrated.fontSize" = sizes.terminal * 4.0 / 3.0;
"chat.editor.fontSize" = sizes.terminal * 4.0 / 3.0;
# other factors (9/14, 13/14, 56/14) based on default for given value
# divided by default for `editor.fontSize` (14) from
# https://code.visualstudio.com/docs/getstarted/settings#_default-settings.
"editor.minimap.sectionHeaderFontSize" =
sizes.terminal * 4.0 / 3.0 * 9.0 / 14.0;
"scm.inputFontSize" = sizes.terminal * 4.0 / 3.0 * 13.0 / 14.0;
"screencastMode.fontSize" = sizes.terminal * 4.0 / 3.0 * 56.0 / 14.0;
};
};
};
}