11.stylix/modules/vscode/hm.nix
NAHO 3fb65013f7 treewide: rename mkTarget's configElements and extraOptions options
Rename mkTarget's 'configElements' argument to 'config' and
'extraOptions' to 'options' to provide a more transparent interface with
the underlying Nixpkgs module system.

(cherry picked from commit 16df6b8448)
2025-12-10 07:14:37 -10:00

58 lines
1.7 KiB
Nix

{
mkTarget,
pkgs,
config,
lib,
...
}:
mkTarget {
name = "vscode";
humanName = "VSCode";
options.profileNames = lib.mkOption {
description = "The VSCode profile names to apply styling on.";
type = lib.types.listOf lib.types.str;
default = [ "default" ];
};
config = [
(
{ cfg }:
{
warnings =
lib.optional (config.programs.vscode.enable && cfg.profileNames == [ ])
''stylix: vscode: `config.stylix.targets.vscode.profileNames` is empty. No theming will be applied. Add a profile or disable this warning by setting `stylix.targets.vscode.enable = false`.'';
}
)
(
{ cfg, colors }:
{
programs.vscode.profiles = lib.genAttrs cfg.profileNames (_: {
extensions = lib.singleton (
pkgs.runCommandLocal "stylix-vscode"
{
vscodeExtUniqueId = "stylix.stylix";
vscodeExtPublisher = "stylix";
version = "0.0.0";
theme = builtins.toJSON (import ./templates/theme.nix colors);
passAsFile = [ "theme" ];
}
''
mkdir -p "$out/share/vscode/extensions/$vscodeExtUniqueId/themes"
ln -s ${./package.json} "$out/share/vscode/extensions/$vscodeExtUniqueId/package.json"
cp "$themePath" "$out/share/vscode/extensions/$vscodeExtUniqueId/themes/stylix.json"
''
);
});
}
)
(
{ cfg, fonts }:
{
programs.vscode.profiles = lib.genAttrs cfg.profileNames (_: {
userSettings = import ./templates/settings.nix fonts;
});
}
)
];
}