From 90e1a217012e96ccd1718d20ad46489cbba43f5c Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Fri, 3 Apr 2026 21:07:12 +0100 Subject: [PATCH] feat(home): enhance user environment and dynamic theming - Implement dynamic palette generation from colors.toml themes - Update script wrapper to handle non-executable source files - Integrate Stylix for unified application theming - Add state-based logic for persistent dynamic configurations --- modules/home/alacritty.nix | 4 ++-- modules/home/default.nix | 9 +++++---- modules/home/nightlight.nix | 3 ++- modules/home/scripts.nix | 15 +++++++++++++-- modules/home/stylix.nix | 5 +++-- themes/nomarchy-palettes.nix | 7 ++++--- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/modules/home/alacritty.nix b/modules/home/alacritty.nix index 6eae803..921206a 100644 --- a/modules/home/alacritty.nix +++ b/modules/home/alacritty.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { programs.alacritty = { @@ -15,7 +15,7 @@ normal = { family = config.nomarchy.fonts.monospace; style = "Regular"; }; bold = { family = config.nomarchy.fonts.monospace; style = "Bold"; }; italic = { family = config.nomarchy.fonts.monospace; style = "Italic"; }; - size = 9; + size = lib.mkForce 9; }; window = { padding = { x = 14; y = 14; }; diff --git a/modules/home/default.nix b/modules/home/default.nix index 9ded849..685d5bc 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -2,11 +2,11 @@ let palettes = import ../../themes/nomarchy-palettes.nix; - # Reads the state file. If it doesn't exist, defaults to dracula. + # Reads the state file. If it doesn't exist, defaults to nord. stateFile = "${config.home.homeDirectory}/.config/home-manager/theme-state.nix"; activeThemeName = if builtins.pathExists stateFile then lib.removeSuffix "\n" (builtins.readFile stateFile) - else "dracula"; + else "nord"; userPackagesFile = "${config.home.homeDirectory}/.config/home-manager/user-packages.json"; userPackages = if builtins.pathExists userPackagesFile then let @@ -31,13 +31,14 @@ in ./theme-switcher.nix ./scripts.nix ./configs.nix + ./swayosd.nix ]; - colorScheme = palettes.${activeThemeName} or palettes.dracula; + colorScheme = palettes.${activeThemeName} or palettes.nord; home.packages = with pkgs; [ firefox - thunar + xfce.thunar imv mpv neovim diff --git a/modules/home/nightlight.nix b/modules/home/nightlight.nix index 98b7f26..5e19202 100644 --- a/modules/home/nightlight.nix +++ b/modules/home/nightlight.nix @@ -5,10 +5,11 @@ let hyprsunsetState = if builtins.pathExists stateFile then builtins.fromJSON (builtins.readFile stateFile) else { enabled = false; temperature = 4000; }; + temp = toString (if hyprsunsetState.enabled then hyprsunsetState.temperature else 6500); in { services.hyprsunset = { enable = true; # Always enabled, we control via IPC and state - temperature = if hyprsunsetState.enabled then hyprsunsetState.temperature else 6500; + extraArgs = [ "--temperature" temp ]; }; } diff --git a/modules/home/scripts.nix b/modules/home/scripts.nix index 97a2afe..a3de21a 100644 --- a/modules/home/scripts.nix +++ b/modules/home/scripts.nix @@ -21,6 +21,12 @@ let brightnessctl playerctl pamixer + pulseaudio + wireplumber + swayosd + gawk + curl + wget # Add any others commonly used in bin/ ]; @@ -34,10 +40,15 @@ let installPhase = '' mkdir -p $out/bin cp -r * $out/bin/ + chmod +x $out/bin/* # Wrap every script to ensure dependencies are in PATH - find $out/bin -type f -exec wrapProgram {} \ - --prefix PATH : ${lib.makeBinPath nomarchy-deps} \; + for file in $out/bin/*; do + if [ -f "$file" ]; then + wrapProgram "$file" \ + --prefix PATH : ${lib.makeBinPath nomarchy-deps} + fi + done ''; }; in diff --git a/modules/home/stylix.nix b/modules/home/stylix.nix index 68c9bf4..70926da 100644 --- a/modules/home/stylix.nix +++ b/modules/home/stylix.nix @@ -7,7 +7,7 @@ let themeStateFile = "${config.home.homeDirectory}/.config/home-manager/theme-state.nix"; activeThemeName = if builtins.pathExists themeStateFile then lib.removeSuffix "\n" (builtins.readFile themeStateFile) - else "dracula"; + else "nord"; wallpaperStateFile = "${config.home.homeDirectory}/.config/home-manager/wallpaper-state.nix"; activeWallpaper = if builtins.pathExists wallpaperStateFile then @@ -15,13 +15,14 @@ let else "${../../themes/catppuccin/backgrounds/1-totoro.png}"; # Fallback # Map nix-colors palette to a format Stylix expects (attrset of hex strings) - currentPalette = (palettes.${activeThemeName} or palettes.dracula).palette; + currentPalette = (palettes.${activeThemeName} or palettes.nord).palette; in { imports = [ inputs.stylix.homeModules.stylix ]; stylix = { enable = true; + enableReleaseChecks = false; image = activeWallpaper; base16Scheme = currentPalette; diff --git a/themes/nomarchy-palettes.nix b/themes/nomarchy-palettes.nix index a99cbcd..255f787 100644 --- a/themes/nomarchy-palettes.nix +++ b/themes/nomarchy-palettes.nix @@ -2,9 +2,10 @@ let themesDir = ./.; # Get all directories in the themes folder that have a colors.toml file - directories = builtins.attrNames ( - builtins.filterAttrs (name: type: type == "directory" && builtins.pathExists (themesDir + "/${name}/colors.toml")) (builtins.readDir themesDir) - ); + allEntries = builtins.readDir themesDir; + directories = builtins.filter (name: + allEntries.${name} == "directory" && builtins.pathExists (themesDir + "/${name}/colors.toml") + ) (builtins.attrNames allEntries); readTheme = name: let