Generic progress

This commit is contained in:
Jan Bulthuis 2024-07-18 22:21:06 +02:00
parent dd327a977a
commit 4f49ea8383
15 changed files with 173 additions and 31 deletions

11
default.nix Normal file
View File

@ -0,0 +1,11 @@
{ ... }:
{
imports = [
# Import modules
./modules/default.nix
# Import custom packages
./pkgs/default.nix
];
}

View File

@ -2,8 +2,8 @@
{ {
imports = [ imports = [
# Import modules # Import environment
../modules/default.nix ../default.nix
# TODO: Remove later # TODO: Remove later
../merged.nix ../merged.nix

View File

@ -256,19 +256,19 @@ in {
# ]; # ];
# }; # };
fonts.fontconfig.localConf = '' # fonts.fontconfig.localConf = ''
<alias> # <alias>
<family>Dina</family> # <family>Dina</family>
<prefer> # <prefer>
<family>Dina</family> # <family>Dina</family>
<family>Cozette</family> # <family>Cozette</family>
<family>CozetteVector</family> # <family>Cozette Vector</family>
<family>Fixed</family> # <family>Fixed</family>
<family>Symbols Nerd Font Mono</family> # <family>Symbols Nerd Font Mono</family>
<family>WenQuanYi Bitmap Song</family> # <family>WenQuanYi Bitmap Song</family>
</prefer> # </prefer>
</alias> # </alias>
''; # '';
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget

View File

@ -3,6 +3,19 @@
with lib; with lib;
let let
cfg = config.modules.fontconfig; cfg = config.modules.fontconfig;
aliasConfig = font: ''
<alias>
<family>${font.name}</family>
<prefer>
<family>${font.name}</family>
${concatStrings (map (font: " <family>${font}</family>\n") font.fallbackFonts)}
</prefer>
</alias>
'';
configContent = concatStrings (map (font: aliasConfig config.theming.fonts.pkgs.${font}) config.theming.fonts.installed);
in { in {
options.modules.fontconfig = { options.modules.fontconfig = {
enable = mkEnableOption "fontconfig"; enable = mkEnableOption "fontconfig";
@ -27,5 +40,18 @@ in {
]; ];
}; };
}; };
home.file.".config/fontconfig/conf.d/20-family-fallbacks.conf" = {
enable = true;
text = ''
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
${configContent}
</fontconfig>
'';
};
}; };
} }

View File

@ -73,7 +73,8 @@ let
}) enabledFonts)); }) enabledFonts));
# Convert set of fonts to list of packages # Convert set of fonts to list of packages
fontPackageList = map (font: cfg.fonts.pkgs.${font.name}.package) (attrsToList fontPackages); fontNameList = map (font: font.name) (attrsToList fontPackages);
fontPackageList = map (font: cfg.fonts.pkgs.${font}.package) fontNameList;
in { in {
imports = [ imports = [
# Import all themes # Import all themes
@ -81,12 +82,6 @@ in {
./themes/catppuccin.nix ./themes/catppuccin.nix
]; ];
options.testing.test = mkOption {
type = types.anything;
default = traced;
description = "Wowzah";
};
options.modules.theming.enable = mkEnableOption "theming"; options.modules.theming.enable = mkEnableOption "theming";
options.theming = let colors = config.theming.schemeColors; in { options.theming = let colors = config.theming.schemeColors; in {
@ -162,6 +157,12 @@ in {
description = "All available font modules."; description = "All available font modules.";
}; };
installed = mkOption {
type = types.listOf types.str;
default = fontNameList;
description = "List of installed fonts.";
};
serif = mkOption { serif = mkOption {
type = fontModule; type = fontModule;
description = "Default serif font"; description = "Default serif font";

View File

@ -6,5 +6,6 @@
recommendedSize = 9; recommendedSize = 9;
fallbackFonts = [ fallbackFonts = [
"Cozette" "Cozette"
"Symbols Nerd Font Mono"
]; ];
} }

View File

@ -4,5 +4,7 @@
name = "Fira Code"; name = "Fira Code";
package = pkgs.fira-code; package = pkgs.fira-code;
recommendedSize = 12; recommendedSize = 12;
fallbackFonts = []; fallbackFonts = [
"Symbols Nerd Font Mono"
];
} }

View File

@ -0,0 +1,7 @@
{ pkgs, ... }:
{
name = "WenQuanYi Zen Hei";
recommendedSize = 12;
fallbackFonts = [];
}

View File

@ -11,6 +11,10 @@ in {
type = types.anything; type = types.anything;
default = theme.fonts.pkgs."Fira Code"; default = theme.fonts.pkgs."Fira Code";
}; };
fallbackFont = mkOption {
type = types.anything;
default = theme.fonts.pkgs."Symbols Nerd Font Mono";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -34,11 +38,12 @@ in {
userSettings = { userSettings = {
# Font setup # Font setup
"editor.fontFamily" = mkForce cfg.codeFont.name; # TODO: Move the conversion factor to theme settings
"editor.fontSize" = cfg.codeFont.recommendedSize; "editor.fontFamily" = mkForce "'${cfg.codeFont.name}', '${cfg.fallbackFont.name}'";
"editor.fontSize" = mkForce (cfg.codeFont.recommendedSize); # Convert pt to px
"editor.fontLigatures" = true; "editor.fontLigatures" = true;
"terminal.integrated.fontFamily" = mkForce cfg.codeFont.name; "terminal.integrated.fontFamily" = mkForce "'${cfg.codeFont.name}', '${cfg.fallbackFont.name}'";
"terminal.integrated.fontSize" = cfg.codeFont.recommendedSize; "terminal.integrated.fontSize" = mkForce (cfg.codeFont.recommendedSize); # Convert pt to px
# Autoformatting # Autoformatting
"editor.formatOnSave" = true; "editor.formatOnSave" = true;

17
pkgs/default.nix Normal file
View File

@ -0,0 +1,17 @@
{ lib, config, pkgs, ... }:
with lib;
let
mkPackage = path: (mkOption {
type = types.package;
default = (pkgs.callPackage path) {};
description = (mkPackage path).default.name;
});
in {
options.pkgs = {
# Add all custom packages
wqy-zenhei = mkPackage ./fonts/wqy-zenhei.nix;
wqy-microhei = mkPackage ./fonts/wqy-microhei.nix;
wqy-bitmapsong = mkPackage ./fonts/wqy-bitmapsong.nix;
};
}

View File

@ -0,0 +1,33 @@
{ lib, config, pkgs, ... }:
pkgs.stdenv.mkDerivation rec {
pname = "wqy-bitmapsong-pcf";
version = "1.0.0-RC1";
src = pkgs.fetchurl {
url = "mirror://sourceforge/wqy/${pname}-${version}.tar.gz";
#hash = "sha256-r2Vf7ftJCqu7jOc2AqCKaoR/r8eNw2P/OQGqbDOEyl0=";
hash = "sha256-0uvwkRUbvJ0remTnlP8dElRjaBVd6iukNYBTE/CTO7s=";
};
buildInputs = [ pkgs.fontforge ];
buildPhase = ''
newName() {
test "''${1:5:1}" = i && _it=Italic || _it=
case ''${1:6:3} in
400) test -z $it && _weight=Medium ;;
700) _weight=Bold ;;
esac
_pt=''${1%.pcf}
_pt=''${_pt#*-}
echo "WenQuanYi_Bitmap_Song$_weight$_it$_pt"
}
for i in *.pcf; do
fontforge -lang=ff -c "Open(\"$i\"); Generate(\"$(newName $i).otb\")"
done
'';
installPhase = ''
install -Dm644 *.otb -t $out/share/fonts/
'';
}

View File

@ -0,0 +1,19 @@
{ lib, config, pkgs, ... }:
pkgs.stdenv.mkDerivation rec {
pname = "wqy-microhei";
version = "0.2.0-beta";
src = pkgs.fetchurl {
url = "mirror://sourceforge/wqy/${pname}-${version}.tar.gz";
hash = "sha256-KAKsgCOqNqZupudEWFTjoHjTd///QhaTQb0jeHH3IT4=";
};
installPhase = ''
runHook preInstall
install -Dm644 *.ttc -t $out/share/fonts/
runHook postInstall
'';
}

19
pkgs/fonts/wqy-zenhei.nix Normal file
View File

@ -0,0 +1,19 @@
{ lib, config, pkgs, ... }:
pkgs.stdenv.mkDerivation rec {
pname = "wqy-zenhei";
version = "0.9.45";
src = pkgs.fetchurl {
url = "mirror://sourceforge/wqy/${pname}-${version}.tar.gz";
hash = "sha256-5LfjBkdb+UJ9F1dXjw5FKJMMhMROqj8WfUxC8RDuddY=";
};
installPhase = ''
runHook preInstall
install -Dm644 *.ttc -t $out/share/fonts/
runHook postInstall
'';
}

View File

@ -3,6 +3,7 @@
{ config, ... }: { config, ... }:
{ {
# TODO: Remove later
imports = [ imports = [
./janMerged.nix ./janMerged.nix
]; ];

View File

@ -289,10 +289,10 @@ in {
enable = true; enable = true;
# Dark mode # Dark mode
#theme = { theme = {
# name = "Adwaita-dark"; name = "Adwaita-dark";
# package = pkgs.gnome-themes-extra; package = pkgs.gnome-themes-extra;
#}; };
# Disable CSD # Disable CSD
gtk3.extraCss = css; gtk3.extraCss = css;