feat: drafted out open dyslexic font for vscode
This commit is contained in:
parent
80ad498f94
commit
75dcac8d17
4 changed files with 51 additions and 1 deletions
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
options.programs.vscode.profiles = lib.mkOption {
|
||||
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
|
||||
options = {
|
||||
extraExtensions.openDyslexicFont = {
|
||||
enable = lib.mkEnableOption "should OpenDyslexic font be set as the default font for VSCode";
|
||||
package = lib.mkPackageOption pkgs "nerd-fonts.open-dyslexic" {
|
||||
default = ["nerd-fonts" "open-dyslexic"];
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkIf config.extraExtensions.openDyslexicFont.enable {
|
||||
userSettings = {
|
||||
"editor.fontFamily" = "'OpenDyslexicM Nerd Font Mono', 'OpenDyslexic', monospace";
|
||||
"editor.fontSize" = 14;
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
||||
config = let
|
||||
enabledProfiles =
|
||||
lib.filter (profile: profile.extraExtensions.openDyslexicFont.enable or false)
|
||||
(lib.attrValues config.programs.vscode.profiles);
|
||||
|
||||
anyProfileUsesOpenDyslexicFont = enabledProfiles != [];
|
||||
|
||||
fontPackages = lib.unique (map (profile: profile.extraExtensions.openDyslexicFont.package) enabledProfiles);
|
||||
in {
|
||||
# Ensure OpenDyslexic font packages are installed when any VSCode profile uses them
|
||||
home.packages = fontPackages;
|
||||
|
||||
fonts.fontconfig.enable = lib.mkIf anyProfileUsesOpenDyslexicFont true;
|
||||
|
||||
# Add assertion to ensure the fonts are available
|
||||
assertions =
|
||||
map (fontPkg: {
|
||||
assertion = lib.elem fontPkg config.home.packages;
|
||||
message = "OpenDyslexic font package '${fontPkg.name or "unknown"}' must be installed when using openDyslexicFont extension for VSCode.";
|
||||
})
|
||||
fontPackages;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue