fonts: support fallback fonts
Alternative to #198 . It is a big breaking change to the config. If you set the fonts you now need to add []. For example:
serif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
};
Becomes:
# v--- IMPORTANT!
serif = [{
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
}];
#^-- IMPORTANT!
I'm getting build issues when using this branch 🥲
I'll look over the diff to try and debug it.
This is the build log: https://github.com/jalil-salame/NixOsConfig/actions/runs/7276308829
I think I found the issue
I didn't :c
It still fails: https://github.com/jalil-salame/NixOsConfig/actions/runs/7278474766
If you manage to catch something I missed then please tell me.
Not sure why this is failing - from the error message my best guess would be that we are using
packagesomewhere where we should be using{ name, package }.
I will grep for this case again as soon as I have time.
Not sure why this is failing - from the error message my best guess would be that we are using
packagesomewhere where we should be using{ name, package }.I will grep for this case again as soon as I have time.
I'm confused; I couldn't find this case anywhere but changing the functions to catAttrs fixed the build issues...
Strange, I wonder if the issue is actually fixed or if catAttrs just filtered it out.
Collect each attribute named
attrfrom a list of attribute sets. Sets that don't contain the named attribute are ignored.
Related:
- https://github.com/nix-community/home-manager/pull/2732
Job failure is unrelated to my changes, it probably needs to be rerun
Should be re-running now.
It passed :tada: this PR is now ready to be merged c:
Rebased on top of master and addressed conflicts so it can be merged. Is anything blocking this? I don't want to keep going back and fixing small conflicts on this PR.
The following patch applies this PR on my Home Manager configuration:
From 5f88a66d30bf014109ce8a41350447621d100515 Mon Sep 17 00:00:00 2001
From: NAHO <[email protected]>
Date: Fri, 9 Feb 2024 23:04:41 +0100
Subject: [PATCH] feat(modules/stylix): support fallback fonts
---
flake.lock | 11 ++++-----
flake.nix | 2 +-
modules/stylix/default.nix | 46 ++++++++++++++++++++++----------------
3 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/flake.lock b/flake.lock
index 8b35089..f58efc3 100644
--- a/flake.lock
+++ b/flake.lock
@@ -555,15 +555,16 @@
]
},
"locked": {
- "lastModified": 1707414210,
- "narHash": "sha256-MJ4deL9tTzowkGpW9Iq+k3cSKo2gnvyIkIuFctNz/dQ=",
- "owner": "danth",
+ "lastModified": 1707499046,
+ "narHash": "sha256-KTAvqoFbvUmzfPgN3vxlr8FABlbJ9gbwRTYtSQ3HfWw=",
+ "owner": "jalil-salame",
"repo": "stylix",
- "rev": "f3b302dd9bb66fcdd1ed3f185068a5f1000eb863",
+ "rev": "20e410269dc0432e6884a1a31403951abf6c155f",
"type": "github"
},
"original": {
- "owner": "danth",
+ "owner": "jalil-salame",
+ "ref": "fallback-fonts-v2",
"repo": "stylix",
"type": "github"
}
diff --git a/flake.nix b/flake.nix
index 97da286..a1c6fa2 100644
--- a/flake.nix
+++ b/flake.nix
@@ -73,7 +73,7 @@
nixpkgs.follows = "nixpkgs";
};
- url = "github:danth/stylix";
+ url = "github:jalil-salame/stylix/fallback-fonts-v2";
};
# Add the 'systems' input for consistent versioning across inputs.
diff --git a/modules/stylix/default.nix b/modules/stylix/default.nix
index a758aa5..1365865 100644
--- a/modules/stylix/default.nix
+++ b/modules/stylix/default.nix
@@ -17,25 +17,33 @@
};
fonts = {
- emoji = {
- package = pkgs.noto-fonts-emoji;
- name = "Noto Color Emoji";
- };
-
- monospace = {
- package = pkgs.nerdfonts.override {fonts = ["FiraCode"];};
- name = "FiraCodeNerdFont";
- };
-
- sansSerif = {
- package = pkgs.ibm-plex;
- name = "IBMPlexSans";
- };
-
- serif = {
- package = pkgs.crimson;
- name = "Crimson";
- };
+ emoji = [
+ {
+ package = pkgs.noto-fonts-emoji;
+ name = "Noto Color Emoji";
+ }
+ ];
+
+ monospace = [
+ {
+ package = pkgs.nerdfonts.override {fonts = ["FiraCode"];};
+ name = "FiraCodeNerdFont";
+ }
+ ];
+
+ sansSerif = [
+ {
+ package = pkgs.ibm-plex;
+ name = "IBMPlexSans";
+ }
+ ];
+
+ serif = [
+ {
+ package = pkgs.crimson;
+ name = "Crimson";
+ }
+ ];
sizes = {
terminal = 7;
--
2.43.0
Unfortunately, I encounter the following build error:
$ home-manager switch --flake <FLAKE>
error:
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'home-manager-generation'
whose name attribute is located at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/pkgs/stdenv/generic/make-derivation.nix:352:7
… while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/pkgs/build-support/trivial-builders/default.nix:98:16:
97| enableParallelBuilding = true;
98| inherit buildCommand name;
| ^
99| passAsFile = [ "buildCommand" ]
(stack trace truncated; use '--show-trace' to show the full trace)
error: infinite recursion encountered
at «none»:0: (source not available)
For reference, the following follow-up patch still causes the infinite recursion encountered error:
From a82f82470a83a7ea08c514d3f02ec8f0db10d15d Mon Sep 17 00:00:00 2001
From: NAHO <[email protected]>
Date: Fri, 9 Feb 2024 23:18:34 +0100
Subject: [PATCH] feat(modules/stylix): set 'monospace' font to default
---
modules/stylix/default.nix | 7 -------
1 file changed, 7 deletions(-)
diff --git a/modules/stylix/default.nix b/modules/stylix/default.nix
index 1365865..7325a01 100644
--- a/modules/stylix/default.nix
+++ b/modules/stylix/default.nix
@@ -24,13 +24,6 @@
}
];
- monospace = [
- {
- package = pkgs.nerdfonts.override {fonts = ["FiraCode"];};
- name = "FiraCodeNerdFont";
- }
- ];
-
sansSerif = [
{
package = pkgs.ibm-plex;
--
2.43.0
The following patch applies this PR on my Home Manager configuration:
You should be able to remove the [], because we coerce font to fontList. I recently rebased this PR. I might've introduced errors then; my NixOS configuration uses this directly, but I haven't updated the flake: https://github.com/jalil-salame/configuration.nix
You should be able to remove the
[], because we coercefonttofontList.
If the following patch is what you mean, then I am still receiving the same infinite recursion error:
From 559ce887a081d6d9e157693bb91cfccebbb17894 Mon Sep 17 00:00:00 2001
From: NAHO <[email protected]>
Date: Fri, 9 Feb 2024 23:33:55 +0100
Subject: [PATCH] fix(modules/stylix): convert list to attribute set
---
modules/stylix/default.nix | 46 ++++++++++++++++----------------------
1 file changed, 19 insertions(+), 27 deletions(-)
diff --git a/modules/stylix/default.nix b/modules/stylix/default.nix
index 1365865..a758aa5 100644
--- a/modules/stylix/default.nix
+++ b/modules/stylix/default.nix
@@ -17,33 +17,25 @@
};
fonts = {
- emoji = [
- {
- package = pkgs.noto-fonts-emoji;
- name = "Noto Color Emoji";
- }
- ];
-
- monospace = [
- {
- package = pkgs.nerdfonts.override {fonts = ["FiraCode"];};
- name = "FiraCodeNerdFont";
- }
- ];
-
- sansSerif = [
- {
- package = pkgs.ibm-plex;
- name = "IBMPlexSans";
- }
- ];
-
- serif = [
- {
- package = pkgs.crimson;
- name = "Crimson";
- }
- ];
+ emoji = {
+ package = pkgs.noto-fonts-emoji;
+ name = "Noto Color Emoji";
+ };
+
+ monospace = {
+ package = pkgs.nerdfonts.override {fonts = ["FiraCode"];};
+ name = "FiraCodeNerdFont";
+ };
+
+ sansSerif = {
+ package = pkgs.ibm-plex;
+ name = "IBMPlexSans";
+ };
+
+ serif = {
+ package = pkgs.crimson;
+ name = "Crimson";
+ };
sizes = {
terminal = 7;
--
2.43.0
I recently rebased this PR. I might've introduced errors then; my NixOS configuration uses this directly, but I haven't updated the flake: https://github.com/jalil-salame/configuration.nix
I see that your NixOS configuration still uses []: https://github.com/jalil-salame/configuration.nix/commit/a3ce3b2944791604693dde69a3494faa2d09b08d.
Am I improperly applying your patch, or is there a bug?
Even entirely removing stylix.fonts causes the infinite recursion error:
From 6a75eccd8e8256061131651650d9e29bc8367786 Mon Sep 17 00:00:00 2001
From: NAHO <[email protected]>
Date: Fri, 9 Feb 2024 23:40:57 +0100
Subject: [PATCH] feat(modules/stylix): apply default fonts
---
modules/stylix/default.nix | 26 --------------------------
1 file changed, 26 deletions(-)
diff --git a/modules/stylix/default.nix b/modules/stylix/default.nix
index a758aa5..ef16b06 100644
--- a/modules/stylix/default.nix
+++ b/modules/stylix/default.nix
@@ -16,32 +16,6 @@
size = 22;
};
- fonts = {
- emoji = {
- package = pkgs.noto-fonts-emoji;
- name = "Noto Color Emoji";
- };
-
- monospace = {
- package = pkgs.nerdfonts.override {fonts = ["FiraCode"];};
- name = "FiraCodeNerdFont";
- };
-
- sansSerif = {
- package = pkgs.ibm-plex;
- name = "IBMPlexSans";
- };
-
- serif = {
- package = pkgs.crimson;
- name = "Crimson";
- };
-
- sizes = {
- terminal = 7;
- };
- };
-
image = pkgs.fetchurl {
url = "https://www.pixelstalk.net/wp-content/uploads/2016/05/Epic-Anime-Awesome-Wallpapers.jpg";
sha256 = "enQo3wqhgf0FEPHj2coOCvo7DuZv+x5rL/WIo4qPI50=";
--
2.43.0
Either the breaking change adoption is unclear, or a bug has been introduced.
You should be able to remove the
[], because we coercefonttofontList.If the following patch is what you mean, then I am still receiving the same
infinite recursionerror:From 559ce887a081d6d9e157693bb91cfccebbb17894 Mon Sep 17 00:00:00 2001 From: NAHO <[email protected]> Date: Fri, 9 Feb 2024 23:33:55 +0100 Subject: [PATCH] fix(modules/stylix): convert list to attribute set --- modules/stylix/default.nix | 46 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/modules/stylix/default.nix b/modules/stylix/default.nix index 1365865..a758aa5 100644 --- a/modules/stylix/default.nix +++ b/modules/stylix/default.nix @@ -17,33 +17,25 @@ }; fonts = { - emoji = [ - { - package = pkgs.noto-fonts-emoji; - name = "Noto Color Emoji"; - } - ]; - - monospace = [ - { - package = pkgs.nerdfonts.override {fonts = ["FiraCode"];}; - name = "FiraCodeNerdFont"; - } - ]; - - sansSerif = [ - { - package = pkgs.ibm-plex; - name = "IBMPlexSans"; - } - ]; - - serif = [ - { - package = pkgs.crimson; - name = "Crimson"; - } - ]; + emoji = { + package = pkgs.noto-fonts-emoji; + name = "Noto Color Emoji"; + }; + + monospace = { + package = pkgs.nerdfonts.override {fonts = ["FiraCode"];}; + name = "FiraCodeNerdFont"; + }; + + sansSerif = { + package = pkgs.ibm-plex; + name = "IBMPlexSans"; + }; + + serif = { + package = pkgs.crimson; + name = "Crimson"; + }; sizes = { terminal = 7; -- 2.43.0I recently rebased this PR. I might've introduced errors then; my NixOS configuration uses this directly, but I haven't updated the flake: https://github.com/jalil-salame/configuration.nix
I see that your NixOS configuration still uses
[]: https://github.com/jalil-salame/configuration.nix/commit/a3ce3b2944791604693dde69a3494faa2d09b08d.
Yup, I use it because I set a fallback font (NerdFont symbols only), but if I didn't it is not necessary.
Am I improperly applying your patch, or is there a bug?
There probably is a bug. Thanks for noticing.
So far what I can tell is that dunst(?) is accessing the fonts before they are fully evaluated, but I need to look more into it before I come to a conclusion and can push a fix.
Am I improperly applying your patch, or is there a bug?
There probably is a bug. Thanks for noticing.
So far what I can tell is that dunst(?) is accessing the fonts before they are fully evaluated, but I need to look more into it before I come to a conclusion and can push a fix.
Mark the PR as ready once it's intended for review.
Am I improperly applying your patch, or is there a bug?
There probably is a bug. Thanks for noticing.
So far what I can tell is that dunst(?) is accessing the fonts before they are fully evaluated, but I need to look more into it before I come to a conclusion and can push a fix.
Mark the PR as ready once it's intended for review.
Sorry about that, I haven't had time to fix this. It broke locally so I had to rebase it, but I don't have time to look into the issue...
I can't figure out what is causing the infinite recursion in @trueNAHO 's case. I'll try removing the coercing code and checking again.
Removing the coercion to a list did not work T-T.
I don't know what is going on with the infinite recursion, it was not the coercing code, so it probably has to do with builtins.head being eager while we need some construct like lib.mkIf instead. I don't know how to build such a construct though, so I give up. Feel free to take over or close this.
I can't figure out what is causing the infinite recursion in @trueNAHO 's case. I'll try removing the coercing code and checking again.
Do you not encounter a infinite recursion encountered error?
I can't figure out what is causing the infinite recursion in @trueNAHO 's case. I'll try removing the coercing code and checking again.
Do you not encounter a
infinite recursion encounterederror?
I do encounter it, I just could not find the cause. I tried turning off different parts of the config, but nothing worked.
Do you not encounter a
infinite recursion encounterederror?I do encounter it, I just could not find the cause. I tried turning off different parts of the config, but nothing worked.
Simplifying the PR with https://github.com/danth/stylix/pull/201#discussion_r1590336460 does not resolve the issue. This seems to be a rather nasty infinite recursion encountered error...
However, the PR itself seems fine. I assume the problem stems from something seemingly unrelated within Stylix.
Would it not be better to supersede this PR with the one mentioned in https://github.com/danth/stylix/issues/216#issuecomment-1921235916? Although that PR would need to be superseded as well to resolve the pending suggestions (and attract new attention).
Would it not be better to supersede this PR with the one mentioned in #216 (comment)? Although that PR would need to be superseded as well to resolve the pending suggestions (and attract new attention).
Ideally yes, but it has been open for ~2 years now
Would it not be better to supersede this PR with the one mentioned in #216 (comment)? Although that PR would need to be superseded as well to resolve the pending suggestions (and attract new attention).
Ideally yes, but it has been open for ~2 years now
https://github.com/nix-community/home-manager/pull/2732 has been merged.
Would it not be better to supersede this PR with the one mentioned in #216 (comment)? Although that PR would need to be superseded as well to resolve the pending suggestions (and attract new attention).
Ideally yes, but it has been open for ~2 years now
:tada: great work! Thanks! Feel free to close this PR then!
🎉 great work! Thanks! Feel free to close this PR then!
Does https://github.com/nix-community/home-manager/pull/2732 cover what you wanted to do with this PR?
Not really, what I'd want is to pull the defaultFonts.* and get my apps to follow it (specifically Wezterm). But this can be done using a different PR