From dd327a977a7001628bc7ecd64bb16125327631ac Mon Sep 17 00:00:00 2001 From: Jan Bulthuis Date: Thu, 18 Jul 2024 18:13:19 +0200 Subject: [PATCH] More progress --- merged.nix | 1 + modules/default.nix | 4 +- modules/fontconfig/default.nix | 21 ++++++++++ .../modules/desktop/window-manager/river.nix | 5 +-- modules/users/modules/theming/default.nix | 25 ++++++++++- modules/users/modules/vscode/default.nix | 41 +++++++++++++++++-- users/janMerged.nix | 9 ++-- 7 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 modules/fontconfig/default.nix diff --git a/merged.nix b/merged.nix index a5ee2c1..b8a6f63 100644 --- a/merged.nix +++ b/merged.nix @@ -255,6 +255,7 @@ in { # # "Noto Color Emoji" # ]; # }; + fonts.fontconfig.localConf = '' Dina diff --git a/modules/default.nix b/modules/default.nix index 1b43ab1..4c66d64 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,6 +3,7 @@ with lib; { imports = [ # Import modules + ./fontconfig/default.nix ./greeter/greetd/default.nix ./greeter/greetd/tuigreet.nix ./locale/default.nix @@ -16,8 +17,9 @@ with lib; { config.modules = { # Enable default modules + fontconfig.enable = mkDefault true; neovim.enable = mkDefault true; tuigreet.enable = mkDefault true; tailscale.enable = mkDefault true; }; -} \ No newline at end of file +} diff --git a/modules/fontconfig/default.nix b/modules/fontconfig/default.nix new file mode 100644 index 0000000..ffe5275 --- /dev/null +++ b/modules/fontconfig/default.nix @@ -0,0 +1,21 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + cfg = config.modules.fontconfig; +in { + options.modules.fontconfig = { + enable = mkEnableOption "fontconfig"; + }; + + config = { + fonts.fontconfig.enable = cfg.enable; + fonts.enableDefaultPackages = false; + fonts.fontconfig.defaultFonts = { + serif = mkDefault []; + sansSerif = mkDefault []; + monospace = mkDefault []; + emoji = mkDefault []; + }; + }; +} diff --git a/modules/users/modules/desktop/window-manager/river.nix b/modules/users/modules/desktop/window-manager/river.nix index 8ce95f3..a6d1e0d 100644 --- a/modules/users/modules/desktop/window-manager/river.nix +++ b/modules/users/modules/desktop/window-manager/river.nix @@ -24,8 +24,7 @@ in { layoutOptions = "-outer-padding ${toString config.theming.layout.windowPadding} -view-padding ${toString config.theming.layout.windowPadding}"; modes = ["normal" "locked"]; tags = [1 2 3 4 5 6 7 8 9]; - # TODO: Replace the base02 color with a named color - waylockOptions = "-init-color 0x${colors.bg} -input-color 0x${config.theming.schemeColors.base02} -fail-color 0x${colors.bg}"; + waylockOptions = "-init-color 0x${colors.bg} -input-color 0x${colors.focused} -fail-color 0x${colors.bg}"; colors = config.theming.colors; @@ -52,7 +51,7 @@ in { border-width = toString config.theming.layout.borderSize; background-color = "0x${colors.bg}"; border-color-focused = "0x${colors.fg}"; - border-color-unfocused = "0x${config.theming.schemeColors.base01}"; # TODO: Change to use named color; + border-color-unfocused = "0x${colors.unfocused}"; # TODO: Change to use named color; border-color-urgent = "0x${colors.fg}"; spawn = [ diff --git a/modules/users/modules/theming/default.nix b/modules/users/modules/theming/default.nix index 7eee820..0ad3e89 100644 --- a/modules/users/modules/theming/default.nix +++ b/modules/users/modules/theming/default.nix @@ -73,7 +73,7 @@ let }) enabledFonts)); # Convert set of fonts to list of packages - fontPackageList = map (font: cfg.fonts.pkgs.${font.name}.package) (attrsToList (traceVal fontPackages)); + fontPackageList = map (font: cfg.fonts.pkgs.${font.name}.package) (attrsToList fontPackages); in { imports = [ # Import all themes @@ -118,6 +118,18 @@ in { type = types.str; default = colors.base05; }; + focused = mkOption { + type = types.str; + default = cfg.colors.fg; + }; + unfocused = mkOption { + type = types.str; + default = colors.base02; + }; + alert = mkOption { + type = types.str; + default = "ffffff"; # TODO: Derive color from theme + }; }; layout = { @@ -191,6 +203,10 @@ in { enable = true; autoEnable = false; + targets = { + vscode.enable = config.modules.vscode.enable; + }; + base16Scheme = cfg.colorScheme; polarity = if cfg.darkMode then "dark" else "light"; @@ -199,6 +215,13 @@ in { sansSerif = getAttrs [ "name" "package" ] cfg.fonts.sansSerif; monospace = getAttrs [ "name" "package" ] cfg.fonts.monospace; emoji = getAttrs [ "name" "package" ] cfg.fonts.emoji; + + sizes = { + applications = mkDefault cfg.fonts.serif.recommendedSize; + desktop = mkDefault cfg.fonts.monospace.recommendedSize; # TODO: See below + popups = mkDefault cfg.fonts.monospace.recommendedSize; # TODO: Add dedicated UI font + terminal = mkDefault cfg.fonts.monospace.recommendedSize; + }; }; }; }; diff --git a/modules/users/modules/vscode/default.nix b/modules/users/modules/vscode/default.nix index b20c085..9c683a8 100644 --- a/modules/users/modules/vscode/default.nix +++ b/modules/users/modules/vscode/default.nix @@ -1,15 +1,48 @@ {config, lib, pkgs, ... }: +with lib; let cfg = config.modules.vscode; + theme = config.theming; in { - options.modules.vscode.enable = lib.mkEnableOption "vscode"; + options.modules.vscode = { + enable = mkEnableOption "vscode"; + codeFont = mkOption { + type = types.anything; + default = theme.fonts.pkgs."Fira Code"; + }; + }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { modules.unfree.allowedPackages = [ "vscode" ]; - home.packages = with pkgs; [ - vscode + theming.fonts.extraFonts = [ + cfg.codeFont ]; + + programs.vscode = { + enable = true; + + extensions = with pkgs.vscode-extensions; [ + eamodio.gitlens + + # Language support + # TODO: Move to separate language modules + bbenoist.nix + rust-lang.rust-analyzer + ]; + + userSettings = { + # Font setup + "editor.fontFamily" = mkForce cfg.codeFont.name; + "editor.fontSize" = cfg.codeFont.recommendedSize; + "editor.fontLigatures" = true; + "terminal.integrated.fontFamily" = mkForce cfg.codeFont.name; + "terminal.integrated.fontSize" = cfg.codeFont.recommendedSize; + + # Autoformatting + "editor.formatOnSave" = true; + }; + }; }; } \ No newline at end of file diff --git a/users/janMerged.nix b/users/janMerged.nix index 5c5e570..b00a199 100644 --- a/users/janMerged.nix +++ b/users/janMerged.nix @@ -31,6 +31,7 @@ in { wtype # waylock playerctl + nix-tree # Fish plugin dependencies # grc @@ -288,10 +289,10 @@ in { enable = true; # Dark mode - theme = { - name = "Adwaita-dark"; - package = pkgs.gnome-themes-extra; - }; + #theme = { + # name = "Adwaita-dark"; + # package = pkgs.gnome-themes-extra; + #}; # Disable CSD gtk3.extraCss = css;