From 3565544f46efc19cf42fc73457d68b69689c55b1 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 28 Dec 2024 11:22:38 +0300 Subject: [PATCH] Wallpaper: Add support for predefined styles. --- option/Wallpaper.nix | 12 ++++++-- system/Stylix.nix | 73 +++++++++++++++++++++++--------------------- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/option/Wallpaper.nix b/option/Wallpaper.nix index 4609140..9612277 100644 --- a/option/Wallpaper.nix +++ b/option/Wallpaper.nix @@ -1,9 +1,13 @@ # Download the wallpaper here. { pkgs, lib, ... }: let - url = "https://i.imgur.com/03KK4WG.jpeg"; - sha256 = "sha256-lCaYGl+Y1iLtslDqAu/HTqpyWgSOnR+bMI0fKSwjW6w="; + url = "https://i.imgur.com/AKsJ3Rl.jpeg"; + sha256 = "sha256-DIgboGiIGJb2bKi7zqb17m7jctEgWyrSI/mSypeV7dQ="; forceContrastText = false; + + # SEE: https://github.com/tinted-theming/schemes + # Warm: "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml" + style = null; in { options.module.wallpaper = { @@ -15,5 +19,9 @@ in default = pkgs.fetchurl { inherit url sha256; }; type = lib.types.path; }; + style = lib.mkOption { + default = style; + type = with lib.types; nullOr (oneOf [ path lines attrs ]); + }; }; } diff --git a/system/Stylix.nix b/system/Stylix.nix index 75942c1..aff4989 100644 --- a/system/Stylix.nix +++ b/system/Stylix.nix @@ -1,41 +1,46 @@ -{ config, ... }: +{ config, lib, ... }: let style = config.module.style; wallpaper = config.module.wallpaper; in { - stylix = { - inherit (config.module.style) cursor; - enable = true; - autoEnable = true; - image = wallpaper.path; - polarity = "dark"; - fonts = with style.font; { - inherit - emoji - monospace - sansSerif - serif - ; - sizes = with size; { - inherit desktop terminal; - applications = application; - popups = popup; + config = lib.mkMerge [ + { + stylix = { + inherit (config.module.style) cursor; + enable = true; + autoEnable = true; + image = wallpaper.path; + polarity = "dark"; + fonts = with style.font; { + inherit + emoji + monospace + sansSerif + serif + ; + sizes = with size; { + inherit desktop terminal; + applications = application; + popups = popup; + }; + }; + opacity = with style.opacity; { + inherit desktop terminal; + applications = application; + popups = popups; + }; }; - }; - opacity = with style.opacity; { - inherit desktop terminal; - applications = application; - popups = popups; - }; - override = - if wallpaper.forceContrastText then - { - base04 = "000000"; - base05 = "ffffff"; - base06 = "ffffff"; - } - else - { }; - }; + } + + (lib.mkIf wallpaper.forceContrastText { + stylix.override = { + base04 = lib.mkForce "000000"; + base05 = lib.mkForce "ffffff"; + base06 = lib.mkForce "ffffff"; + }; + }) + + (lib.mkIf (wallpaper.style != null) { stylix.base16Scheme = wallpaper.style; }) + ]; }