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
This commit is contained in:
Bernardo Magri
2026-04-03 21:07:12 +01:00
parent 14d7a89a84
commit 90e1a21701
6 changed files with 29 additions and 14 deletions

View File

@@ -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; };

View File

@@ -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

View File

@@ -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 ];
};
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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