diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..c0d5694
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,11 @@
+{ ... }:
+
+{
+ imports = [
+ # Import modules
+ ./modules/default.nix
+
+ # Import custom packages
+ ./pkgs/default.nix
+ ];
+}
\ No newline at end of file
diff --git a/machines/laptop.nix b/machines/laptop.nix
index 5eaf703..d74a660 100644
--- a/machines/laptop.nix
+++ b/machines/laptop.nix
@@ -2,8 +2,8 @@
{
imports = [
- # Import modules
- ../modules/default.nix
+ # Import environment
+ ../default.nix
# TODO: Remove later
../merged.nix
diff --git a/merged.nix b/merged.nix
index b8a6f63..20a7202 100644
--- a/merged.nix
+++ b/merged.nix
@@ -256,19 +256,19 @@ in {
# ];
# };
- fonts.fontconfig.localConf = ''
-
- Dina
-
- Dina
- Cozette
- CozetteVector
- Fixed
- Symbols Nerd Font Mono
- WenQuanYi Bitmap Song
-
-
- '';
+ # fonts.fontconfig.localConf = ''
+ #
+ # Dina
+ #
+ # Dina
+ # Cozette
+ # Cozette Vector
+ # Fixed
+ # Symbols Nerd Font Mono
+ # WenQuanYi Bitmap Song
+ #
+ #
+ # '';
# List packages installed in system profile. To search, run:
# $ nix search wget
diff --git a/modules/users/modules/fontconfig/default.nix b/modules/users/modules/fontconfig/default.nix
index 377191f..b3ef4f0 100644
--- a/modules/users/modules/fontconfig/default.nix
+++ b/modules/users/modules/fontconfig/default.nix
@@ -3,6 +3,19 @@
with lib;
let
cfg = config.modules.fontconfig;
+
+ aliasConfig = font: ''
+
+ ${font.name}
+
+
+ ${font.name}
+ ${concatStrings (map (font: " ${font}\n") font.fallbackFonts)}
+
+
+ '';
+
+ configContent = concatStrings (map (font: aliasConfig config.theming.fonts.pkgs.${font}) config.theming.fonts.installed);
in {
options.modules.fontconfig = {
enable = mkEnableOption "fontconfig";
@@ -27,5 +40,18 @@ in {
];
};
};
+
+ home.file.".config/fontconfig/conf.d/20-family-fallbacks.conf" = {
+ enable = true;
+
+ text = ''
+
+
+
+
+ ${configContent}
+
+ '';
+ };
};
}
\ No newline at end of file
diff --git a/modules/users/modules/theming/default.nix b/modules/users/modules/theming/default.nix
index 0ad3e89..3071cf9 100644
--- a/modules/users/modules/theming/default.nix
+++ b/modules/users/modules/theming/default.nix
@@ -73,7 +73,8 @@ let
}) enabledFonts));
# 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 {
imports = [
# Import all themes
@@ -81,12 +82,6 @@ in {
./themes/catppuccin.nix
];
- options.testing.test = mkOption {
- type = types.anything;
- default = traced;
- description = "Wowzah";
- };
-
options.modules.theming.enable = mkEnableOption "theming";
options.theming = let colors = config.theming.schemeColors; in {
@@ -162,6 +157,12 @@ in {
description = "All available font modules.";
};
+ installed = mkOption {
+ type = types.listOf types.str;
+ default = fontNameList;
+ description = "List of installed fonts.";
+ };
+
serif = mkOption {
type = fontModule;
description = "Default serif font";
diff --git a/modules/users/modules/theming/fonts/dina.nix b/modules/users/modules/theming/fonts/dina.nix
index 6fc75b8..3d4e801 100644
--- a/modules/users/modules/theming/fonts/dina.nix
+++ b/modules/users/modules/theming/fonts/dina.nix
@@ -6,5 +6,6 @@
recommendedSize = 9;
fallbackFonts = [
"Cozette"
+ "Symbols Nerd Font Mono"
];
}
\ No newline at end of file
diff --git a/modules/users/modules/theming/fonts/fira-code.nix b/modules/users/modules/theming/fonts/fira-code.nix
index 833a1d8..dca90be 100644
--- a/modules/users/modules/theming/fonts/fira-code.nix
+++ b/modules/users/modules/theming/fonts/fira-code.nix
@@ -4,5 +4,7 @@
name = "Fira Code";
package = pkgs.fira-code;
recommendedSize = 12;
- fallbackFonts = [];
+ fallbackFonts = [
+ "Symbols Nerd Font Mono"
+ ];
}
\ No newline at end of file
diff --git a/modules/users/modules/theming/fonts/wqy-zenhei.nix b/modules/users/modules/theming/fonts/wqy-zenhei.nix
new file mode 100644
index 0000000..a40eed2
--- /dev/null
+++ b/modules/users/modules/theming/fonts/wqy-zenhei.nix
@@ -0,0 +1,7 @@
+{ pkgs, ... }:
+
+{
+ name = "WenQuanYi Zen Hei";
+ recommendedSize = 12;
+ fallbackFonts = [];
+}
\ No newline at end of file
diff --git a/modules/users/modules/vscode/default.nix b/modules/users/modules/vscode/default.nix
index 9c683a8..13f357e 100644
--- a/modules/users/modules/vscode/default.nix
+++ b/modules/users/modules/vscode/default.nix
@@ -11,6 +11,10 @@ in {
type = types.anything;
default = theme.fonts.pkgs."Fira Code";
};
+ fallbackFont = mkOption {
+ type = types.anything;
+ default = theme.fonts.pkgs."Symbols Nerd Font Mono";
+ };
};
config = mkIf cfg.enable {
@@ -34,11 +38,12 @@ in {
userSettings = {
# Font setup
- "editor.fontFamily" = mkForce cfg.codeFont.name;
- "editor.fontSize" = cfg.codeFont.recommendedSize;
+ # TODO: Move the conversion factor to theme settings
+ "editor.fontFamily" = mkForce "'${cfg.codeFont.name}', '${cfg.fallbackFont.name}'";
+ "editor.fontSize" = mkForce (cfg.codeFont.recommendedSize); # Convert pt to px
"editor.fontLigatures" = true;
- "terminal.integrated.fontFamily" = mkForce cfg.codeFont.name;
- "terminal.integrated.fontSize" = cfg.codeFont.recommendedSize;
+ "terminal.integrated.fontFamily" = mkForce "'${cfg.codeFont.name}', '${cfg.fallbackFont.name}'";
+ "terminal.integrated.fontSize" = mkForce (cfg.codeFont.recommendedSize); # Convert pt to px
# Autoformatting
"editor.formatOnSave" = true;
diff --git a/pkgs/default.nix b/pkgs/default.nix
new file mode 100644
index 0000000..66a9b18
--- /dev/null
+++ b/pkgs/default.nix
@@ -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;
+ };
+}
\ No newline at end of file
diff --git a/pkgs/fonts/wqy-bitmapsong.nix b/pkgs/fonts/wqy-bitmapsong.nix
new file mode 100644
index 0000000..23c7630
--- /dev/null
+++ b/pkgs/fonts/wqy-bitmapsong.nix
@@ -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/
+ '';
+}
\ No newline at end of file
diff --git a/pkgs/fonts/wqy-microhei.nix b/pkgs/fonts/wqy-microhei.nix
new file mode 100644
index 0000000..768d8b0
--- /dev/null
+++ b/pkgs/fonts/wqy-microhei.nix
@@ -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
+ '';
+}
\ No newline at end of file
diff --git a/pkgs/fonts/wqy-zenhei.nix b/pkgs/fonts/wqy-zenhei.nix
new file mode 100644
index 0000000..2bdb05a
--- /dev/null
+++ b/pkgs/fonts/wqy-zenhei.nix
@@ -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
+ '';
+}
\ No newline at end of file
diff --git a/users/jan.nix b/users/jan.nix
index 6975d4f..ec3e425 100644
--- a/users/jan.nix
+++ b/users/jan.nix
@@ -3,6 +3,7 @@
{ config, ... }:
{
+ # TODO: Remove later
imports = [
./janMerged.nix
];
diff --git a/users/janMerged.nix b/users/janMerged.nix
index b00a199..fff160b 100644
--- a/users/janMerged.nix
+++ b/users/janMerged.nix
@@ -289,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;