stylix: refactor

This commit is contained in:
2025-12-21 22:25:17 +02:00
parent 62c21f09ba
commit ca6858e6bd
2 changed files with 297 additions and 319 deletions
+277 -319
View File
@@ -5,7 +5,6 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (builtins) fetchurl;
inherit (lib) mkEnableOption mkOption mkIf; inherit (lib) mkEnableOption mkOption mkIf;
inherit (lib) optionalAttrs; inherit (lib) optionalAttrs;
inherit (lib.types) bool str; inherit (lib.types) bool str;
@@ -14,7 +13,7 @@
fromBase16Schemes = f: "${pkgs.base16-schemes}/share/themes/${f}.yaml"; fromBase16Schemes = f: "${pkgs.base16-schemes}/share/themes/${f}.yaml";
interPackage = pkgs.inter-nerdfont; interPackage = pkgs.inter;
iosevkaPackage = pkgs.nerd-fonts.iosevka; iosevkaPackage = pkgs.nerd-fonts.iosevka;
iosevkaTermPackage = pkgs.nerd-fonts.iosevka-term; iosevkaTermPackage = pkgs.nerd-fonts.iosevka-term;
mesloLgPackage = pkgs.nerd-fonts.meslo-lg; mesloLgPackage = pkgs.nerd-fonts.meslo-lg;
@@ -22,336 +21,288 @@
geistMonoPackage = pkgs.nerd-fonts.geist-mono; geistMonoPackage = pkgs.nerd-fonts.geist-mono;
geistPackage = pkgs.geist-font; geistPackage = pkgs.geist-font;
wallpapers = { wallpapers = import ./wallpapers.nix;
abstract = {
squares = fetchurl { interIosevka = {
url = "https://w.wallhaven.cc/full/p9/wallhaven-p91dym.jpg"; serif = {
name = "wallhaven-p91dym.jpg"; package = interPackage;
sha256 = "wnsAhh0Soxm+lxahh+Xc/+CAw/abWgPIkeoOlzNGaDo="; name = "Inter";
};
waves = fetchurl {
url = "https://w.wallhaven.cc/full/5y/wallhaven-5ydl93.png";
name = "wallhaven-5ydl93.png";
sha256 = "fTE2cyn2mkx05+Zn6qcs4+Rb7AYD0uyi6CNznuZYOjw=";
};
}; };
fern-outline = fetchurl {
url = "https://w.wallhaven.cc/full/p9/wallhaven-p9m7ve.png"; monospace = {
name = "wallhaven-p9m7ve.png"; package = iosevkaTermPackage;
sha256 = "0r7dl4fjwv2p5q5ggr4sjsl2h5m0s98k9qhiwkvmwi010lyffkx7"; name = "IosevkaTerm Nerd Font Mono";
};
mountains-pink = fetchurl {
url = "https://w.wallhaven.cc/full/yq/wallhaven-yq7gox.jpg";
name = "wallhaven-yq7gox.jpg";
sha256 = "09s31spp9mq71fgkl1w80nzdc1458p1gjfyi3y6fy14wj2dza0pj";
};
mountains-black = fetchurl {
url = "https://w.wallhaven.cc/full/9d/wallhaven-9djzww.jpg";
name = "wallhaven-9djzww.jpg";
sha256 = "1p2si922i9qs09h8c74lrvx0f284g0xvm7lh85gk1x7lqhn611zm";
};
cyber-dawn = fetchurl {
url = "https://w.wallhaven.cc/full/ym/wallhaven-ymo2y7.png";
name = "wallhaven-ymo2y7.png";
sha256 = "1b3j0hxxy8m25scq42lxsxc99xvr15pha1j4wplgz761asrvxly3";
};
retro-deck = fetchurl {
url = "https://w.wallhaven.cc/full/1q/wallhaven-1q83qg.jpg";
name = "wallhaven-1q83qg.jpg";
sha256 = "QPmG4QTRvubuX6Fy5rmMwYKw4aQdBiH/zGL/PMmUZOk=";
};
nixos-rainbow = fetchurl {
url = "https://w.wallhaven.cc/full/p9/wallhaven-p9pd23.png";
name = "wallhaven-p9pd23.png";
sha256 = "7CMuETntiVUCKhUIdJzX+sf3F47GvuX2a61o4xbEzww=";
};
mountains-sepia = fetchurl {
url = "https://w.wallhaven.cc/full/k8/wallhaven-k89k81.jpg";
name = "wallhaven-k89k81.jpg";
sha256 = "C0lvJ0ff0mCC3i9mmeHZsj/n6Ehkp3jaslVr7VDUB3k=";
};
jcurry-cloud = fetchurl {
url = "https://w.wallhaven.cc/full/7j/wallhaven-7j6wpy.jpg";
name = "wallhaven-je8rwq.jpg";
sha256 = "xsuCYc0mCDkrJZ+BUmEEclAfF17g1n39JHeubtZHP78=";
};
vapor-moon = fetchurl {
url = "https://w.wallhaven.cc/full/lm/wallhaven-lm6d2r.png";
name = "wallhaven-lm6d2r.png";
sha256 = "V07kj2zwFHDwzIN8QE8IFrJMXxDOBoK9C11sQGgTjyQ=";
}; };
}; };
themes = { themes = {
oxocarbon-dark = { dark = {
polarity = "dark"; ashes = {
scheme = fromBase16Schemes "porple"; polarity = "dark";
wallpaper = wallpapers.retro-deck; base16Scheme = fromBase16Schemes "classic-dark";
image = wallpapers.abstract.lambda;
serif = { inherit (interIosevka) serif monospace;
package = iosevkaPackage;
name = "Iosevka Nerd Font Propo"; cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
rose-pine-moon = {
polarity = "dark";
base16Scheme = fromBase16Schemes "rose-pine-moon";
image = wallpapers.cyber-dawn;
inherit (interIosevka) serif monospace;
cursor = {
package = pkgs.nordzy-cursor-theme;
name = "Nordzy-cursors";
size = 24;
};
};
rose-pine = {
polarity = "dark";
base16Scheme = fromBase16Schemes "rose-pine";
image = wallpapers.cyber-dawn;
inherit (interIosevka) serif monospace;
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
kanagawa = {
polarity = "dark";
base16Scheme = fromBase16Schemes "kanagawa";
image = wallpapers.cyber-dawn;
inherit (interIosevka) serif monospace;
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
sandcastle = {
polarity = "dark";
base16Scheme = fromBase16Schemes "sandcastle";
image = wallpapers.abstract.waves;
serif = {
package = geistPackage;
name = "Geist";
};
monospace = {
package = geistMonoPackage;
name = "GeistMono NFM";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
gruvbox-dark-pale = {
polarity = "dark";
base16Scheme = fromBase16Schemes "gruvbox-dark-pale";
image = wallpapers.mountains-sepia;
serif = {
package = geistPackage;
name = "Geist";
};
monospace = {
package = geistMonoPackage;
name = "GeistMono Nerd Font";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
nord = {
polarity = "dark";
base16Scheme = fromBase16Schemes "nord";
image = builtins.fetchurl {
url = "https://w.wallhaven.cc/full/l8/wallhaven-l8l9gq.png";
name = "wallhaven-l8l9gq.png";
sha256 = "0ypr44sg0fn55m1b52dgr1nnscpi2p6rfkjsm7vvrdqw7bafbx2z";
};
inherit (interIosevka) serif monospace;
cursor = {
package = pkgs.nordzy-cursor-theme;
name = "Nordzy-cursors";
size = 32;
};
}; };
monospace = { helios = {
package = iosevkaTermPackage; polarity = "dark";
name = "IosevkaTerm Nerd Font Mono"; base16Scheme = fromBase16Schemes "helios";
image = builtins.fetchurl {
url = "https://w.wallhaven.cc/full/lq/wallhaven-lqorw2.png";
name = "wallhaven-lqorw2.png";
sha256 = "sha256:1rjchjq4pc2jyq8dvpa17mmscv9qcm0h0zv468lsf8s51anpid6p";
};
inherit (interIosevka) serif monospace;
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
}; };
cursor = { sulphurpool = {
package = pkgs.bibata-cursors; polarity = "dark";
name = "Bibata-Modern-Classic"; base16Scheme = fromBase16Schemes "atelier-sulphurpool";
size = 24; image = builtins.fetchurl {
url = "https://w.wallhaven.cc/full/rd/wallhaven-rd5q3m.jpg";
name = "wallhaven-rd5q3m.jpg";
sha256 = "sha256:1sa2739vwwv1xafzjvxlg3kvq26xmcxg6hrwq29q40j617r63sy6";
};
serif = {
package = interPackage;
name = "Inter Nerd Font";
};
monospace = {
package = iosevkaTermPackage;
name = "IosevkaTerm Nerd Font Mono";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
vesper = {
polarity = "dark";
base16Scheme = fromBase16Schemes "vesper";
image = wallpapers.abstract.squares;
serif = {
package = geistPackage;
name = "Geist";
};
monospace = {
package = geistMonoPackage;
name = "GeistMono Nerd Font";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
}; };
}; };
rose-pine-dawn = { light = {
polarity = "light"; rose-pine-dawn = {
scheme = fromBase16Schemes "rose-pine-dawn"; polarity = "light";
wallpaper = wallpapers.cyber-dawn; base16Scheme = fromBase16Schemes "rose-pine-dawn";
image = wallpapers.cyber-dawn;
serif = { serif = {
package = iosevkaPackage; package = iosevkaPackage;
name = "Iosevka Nerd Font Propo"; name = "Iosevka Nerd Font Propo";
}; };
monospace = { monospace = {
package = iosevkaTermPackage; package = iosevkaTermPackage;
name = "IosevkaTerm Nerd Font Mono"; name = "IosevkaTerm Nerd Font Mono";
}; };
cursor = { cursor = {
package = pkgs.bibata-cursors; package = pkgs.bibata-cursors;
name = "Bibata-Modern-Ice"; name = "Bibata-Modern-Ice";
size = 24; size = 24;
}; };
}; nord-light = {
rose-pine-moon = { polarity = "light";
polarity = "dark"; base16Scheme = fromBase16Schemes "nord-light";
scheme = fromBase16Schemes "rose-pine-moon"; image = builtins.fetchurl {
wallpaper = wallpapers.cyber-dawn; url = "https://w.wallhaven.cc/full/l8/wallhaven-l8l9gq.png";
name = "wallhaven-l8l9gq.png";
sha256 = "0ypr44sg0fn55m1b52dgr1nnscpi2p6rfkjsm7vvrdqw7bafbx2z";
};
serif = { serif = {
package = interPackage; package = iosevkaPackage;
name = "Inter Nerd Font"; name = "Iosevka Nerd Font Propo";
}; };
monospace = { monospace = {
package = iosevkaTermPackage; package = iosevkaTermPackage;
name = "IosevkaTerm Nerd Font Mono"; name = "IosevkaTerm Nerd Font Mono";
}; };
cursor = { cursor = {
package = pkgs.bibata-cursors; package = pkgs.nordzy-cursor-theme;
name = "Bibata-Modern-Classic"; name = "Nordzy-cursors-white";
size = 24; size = 32;
};
};
}; };
}; himalaya = {
sandcastle = { # lightly pink like himalayan salt
polarity = "dark"; polarity = "light";
scheme = fromBase16Schemes "sandcastle"; base16Scheme = fromBase16Schemes "atelier-plateau-light";
wallpaper = wallpapers.abstract.waves; image = wallpapers.mountains-pink;
serif = { serif = {
package = geistPackage; package = interPackage;
name = "Geist"; name = "Inter Nerd Font";
}; };
monospace = { monospace = {
package = geistMonoPackage; package = mesloLgPackage;
name = "GeistMono NFM"; name = "MesloLGM Nerd Font Mono";
}; };
cursor = { cursor = {
package = pkgs.bibata-cursors; package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic"; name = "Bibata-Modern-Ice";
size = 24; size = 24;
};
}; };
}; github = {
gruvbox-dark-pale = { polarity = "light";
polarity = "dark"; base16Scheme = fromBase16Schemes "github";
scheme = fromBase16Schemes "gruvbox-dark-pale"; image = wallpapers.abstract.squares;
wallpaper = wallpapers.mountains-sepia;
serif = { serif = {
package = geistPackage; package = geistPackage;
name = "Geist"; name = "Geist Light";
}; };
monospace = { monospace = {
package = geistMonoPackage; package = geistMonoPackage;
name = "GeistMono Nerd Font"; name = "GeistMono Nerd Font";
}; };
cursor = { cursor = {
package = pkgs.bibata-cursors; package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic"; name = "Bibata-Modern-Ice";
size = 24; size = 24;
}; };
};
nord = {
polarity = "dark";
scheme = fromBase16Schemes "nord";
wallpaper = fetchurl {
url = "https://w.wallhaven.cc/full/l8/wallhaven-l8l9gq.png";
name = "wallhaven-l8l9gq.png";
sha256 = "0ypr44sg0fn55m1b52dgr1nnscpi2p6rfkjsm7vvrdqw7bafbx2z";
};
serif = {
package = iosevkaPackage;
name = "Iosevka Nerd Font Propo";
};
monospace = {
package = iosevkaTermPackage;
name = "IosevkaTerm Nerd Font Mono";
};
cursor = {
package = pkgs.nordzy-cursor-theme;
name = "Nordzy-cursors";
size = 32;
};
};
nord-light = {
polarity = "light";
scheme = fromBase16Schemes "nord-light";
wallpaper = fetchurl {
url = "https://w.wallhaven.cc/full/l8/wallhaven-l8l9gq.png";
name = "wallhaven-l8l9gq.png";
sha256 = "0ypr44sg0fn55m1b52dgr1nnscpi2p6rfkjsm7vvrdqw7bafbx2z";
};
serif = {
package = iosevkaPackage;
name = "Iosevka Nerd Font Propo";
};
monospace = {
package = iosevkaTermPackage;
name = "IosevkaTerm Nerd Font Mono";
};
cursor = {
package = pkgs.nordzy-cursor-theme;
name = "Nordzy-cursors-white";
size = 32;
};
};
helios = {
polarity = "dark";
scheme = fromBase16Schemes "helios";
wallpaper = fetchurl {
url = "https://w.wallhaven.cc/full/lq/wallhaven-lqorw2.png";
name = "wallhaven-lqorw2.png";
sha256 = "sha256:1rjchjq4pc2jyq8dvpa17mmscv9qcm0h0zv468lsf8s51anpid6p";
};
serif = {
package = interPackage;
name = "Inter Nerd Font";
};
monospace = {
package = iosevkaTermPackage;
name = "IosevkaTerm Nerd Font Mono";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
sulphurpool = {
polarity = "dark";
scheme = fromBase16Schemes "atelier-sulphurpool";
wallpaper = fetchurl {
url = "https://w.wallhaven.cc/full/rd/wallhaven-rd5q3m.jpg";
name = "wallhaven-rd5q3m.jpg";
sha256 = "sha256:1sa2739vwwv1xafzjvxlg3kvq26xmcxg6hrwq29q40j617r63sy6";
};
serif = {
package = interPackage;
name = "Inter Nerd Font";
};
monospace = {
package = iosevkaTermPackage;
name = "IosevkaTerm Nerd Font Mono";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
himalaya = {
# lightly pink like himalayan salt
polarity = "light";
scheme = fromBase16Schemes "atelier-plateau-light";
wallpaper = wallpapers.mountains-pink;
serif = {
package = interPackage;
name = "Inter Nerd Font";
};
monospace = {
package = mesloLgPackage;
name = "MesloLGM Nerd Font Mono";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Ice";
size = 24;
};
};
vesper = {
polarity = "dark";
scheme = fromBase16Schemes "vesper";
wallpaper = wallpapers.abstract.squares;
serif = {
package = geistPackage;
name = "Geist";
};
monospace = {
package = geistMonoPackage;
name = "GeistMono Nerd Font";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
};
github = {
polarity = "light";
scheme = fromBase16Schemes "github";
wallpaper = wallpapers.abstract.squares;
serif = {
package = geistPackage;
name = "Geist Light";
};
monospace = {
package = geistMonoPackage;
name = "GeistMono Nerd Font";
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Ice";
size = 24;
}; };
}; };
}; };
@@ -373,22 +324,34 @@ in {
type = str; type = str;
default = "nord"; default = "nord";
}; };
polarity = mkOption {
type = lib.types.enum ["dark" "light"];
default = "dark";
};
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
fonts.packages = [pkgs.nerd-fonts.symbols-only]; fonts.packages = [pkgs.nerd-fonts.symbols-only];
stylix = stylix = let
theme = themes.${cfg.polarity}.${cfg.theme};
in
{ {
enable = true;
image = themes.${cfg.theme}.wallpaper;
autoEnable = true; autoEnable = true;
polarity = themes.${cfg.theme}.polarity;
base16Scheme = themes.${cfg.theme}.scheme;
enable = true; enable = true;
# TODO: disable when stylix updates # TODO: disable when stylix updates
enableReleaseChecks = false; enableReleaseChecks = false;
inherit (cfg) polarity;
inherit
(theme)
# image
base16Scheme
;
image = null;
targets.gtksourceview.enable = false;
opacity = { opacity = {
applications = 1.0; applications = 1.0;
@@ -405,19 +368,14 @@ in {
desktop = 13; desktop = 13;
}; };
serif = { inherit (theme) serif monospace;
inherit (themes.${cfg.theme}.serif) package name;
};
sansSerif = config.stylix.fonts.serif; sansSerif = config.stylix.fonts.serif;
monospace = {
inherit (themes.${cfg.theme}.monospace) package name;
};
emoji = config.stylix.fonts.serif; emoji = config.stylix.fonts.serif;
}; };
} }
// optionalAttrs cfg.useCursor { // optionalAttrs cfg.useCursor {
cursor = { cursor = {
inherit (themes.${cfg.theme}.cursor) package name size; inherit (theme.cursor) package name size;
}; };
}; };
}; };
@@ -0,0 +1,20 @@
let
fetchPaper = url: name: sha256: builtins.fetchurl {inherit url name sha256;};
in {
abstract = {
circle = fetchPaper "https://w.wallhaven.cc/full/ml/wallhaven-mlly8k.png" "wallhaven-mlly8k.png" "e5ZxRxZdCf0/fJ9RNurGdhRmMCthK9guJZ1Uf1IbG8E=";
squares = fetchPaper "https://w.wallhaven.cc/full/p9/wallhaven-p91dym.jpg" "wallhaven-p91dym.jpg" "wnsAhh0Soxm+lxahh+Xc/+CAw/abWgPIkeoOlzNGaDo=";
waves = fetchPaper "https://w.wallhaven.cc/full/5y/wallhaven-5ydl93.png" "wallhaven-5ydl93.png" "fTE2cyn2mkx05+Zn6qcs4+Rb7AYD0uyi6CNznuZYOjw=";
lambda = fetchPaper "https://w.wallhaven.cc/full/vp/wallhaven-vpp5m3.png" "wallhaven-vpp5m3.png" "7YBfNjZjE8K9QUF4sUlUp3ao2DD6clXtzxgze7LtJ4Q=";
};
green-red-knight = fetchPaper "https://w.wallhaven.cc/full/po/wallhaven-poo7gj.jpg" "wallhaven-poo7gj.jpg" "fUe4VsYUF0DmgSKWJao2Ag2Y6kbHunYMM5Q28XMEhDI=";
fern-outline = fetchPaper "https://w.wallhaven.cc/full/p9/wallhaven-p9m7ve.png" "wallhaven-p9m7ve.png" "0r7dl4fjwv2p5q5ggr4sjsl2h5m0s98k9qhiwkvmwi010lyffkx7";
mountains-pink = fetchPaper "https://w.wallhaven.cc/full/yq/wallhaven-yq7gox.jpg" "wallhaven-yq7gox.jpg" "09s31spp9mq71fgkl1w80nzdc1458p1gjfyi3y6fy14wj2dza0pj";
mountains-black = fetchPaper "https://w.wallhaven.cc/full/9d/wallhaven-9djzww.jpg" "wallhaven-9djzww.jpg" "1p2si922i9qs09h8c74lrvx0f284g0xvm7lh85gk1x7lqhn611zm";
cyber-dawn = fetchPaper "https://w.wallhaven.cc/full/ym/wallhaven-ymo2y7.png" "wallhaven-ymo2y7.png" "1b3j0hxxy8m25scq42lxsxc99xvr15pha1j4wplgz761asrvxly3";
retro-deck = fetchPaper "https://w.wallhaven.cc/full/1q/wallhaven-1q83qg.jpg" "wallhaven-1q83qg.jpg" "QPmG4QTRvubuX6Fy5rmMwYKw4aQdBiH/zGL/PMmUZOk=";
nixos-rainbow = fetchPaper "https://w.wallhaven.cc/full/p9/wallhaven-p9pd23.png" "wallhaven-p9pd23.png" "7CMuETntiVUCKhUIdJzX+sf3F47GvuX2a61o4xbEzww=";
mountains-sepia = fetchPaper "https://w.wallhaven.cc/full/k8/wallhaven-k89k81.jpg" "wallhaven-k89k81.jpg" "C0lvJ0ff0mCC3i9mmeHZsj/n6Ehkp3jaslVr7VDUB3k=";
jcurry-cloud = fetchPaper "https://w.wallhaven.cc/full/7j/wallhaven-7j6wpy.jpg" "wallhaven-je8rwq.jpg" "xsuCYc0mCDkrJZ+BUmEEclAfF17g1n39JHeubtZHP78=";
vapor-moon = fetchPaper "https://w.wallhaven.cc/full/lm/wallhaven-lm6d2r.png" "wallhaven-lm6d2r.png" "V07kj2zwFHDwzIN8QE8IFrJMXxDOBoK9C11sQGgTjyQ=";
}