dotfiles/hm/style.nix

72 lines
3 KiB
Nix
Raw Normal View History

2023-12-05 23:11:54 +01:00
{ pkgs, config, lib, ... }:
2023-10-29 00:49:22 +02:00
let
# Currently last commit in https://github.com/danth/stylix/pull/194
stylix = builtins.fetchTarball "https://github.com/willemml/stylix/archive/2ed2b0086b41d582aca26e083c19c0e47c8991e3.tar.gz";
2023-12-05 23:11:54 +01:00
polarityFile = "${config.xdg.stateHome}/theme_polarity";
polarityFromFile = if builtins.pathExists polarityFile then lib.strings.fileContents polarityFile else "light";
polarity = if config.frogeye.polarity == "dynamic" then polarityFromFile else config.frogeye.polarity;
2023-12-05 23:11:54 +01:00
phases = [
{ command = "jour"; polarity = "light"; }
{ command = "crepuscule"; polarity = "dark"; }
{ command = "nuit"; polarity = "dark"; }
];
cfg = config.frogeye.desktop.phasesBrightness;
2023-10-29 00:49:22 +02:00
in
{
imports = [ (import stylix).homeManagerModules.stylix ];
stylix = {
2023-12-05 23:11:54 +01:00
base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-${polarity}.yaml";
2023-10-29 00:49:22 +02:00
image = builtins.fetchurl {
url = "https://get.wallhere.com/photo/sunlight-abstract-minimalism-green-simple-circle-light-leaf-wave-material-line-wing-computer-wallpaper-font-close-up-macro-photography-124350.png";
sha256 = "sha256:1zfq3f3v34i45mi72pkfqphm8kbhczsg260xjfl6dbydy91d7y93";
};
# The background is set on some occasions, autorandr + feh do the rest
2023-10-29 12:15:56 +01:00
2023-11-12 21:53:52 +01:00
fonts = {
monospace = {
2023-11-21 21:01:56 +01:00
package = pkgs.nerdfonts.override {
fonts = [ "DejaVuSansMono" ]; # Choose from https://github.com/NixOS/nixpkgs/blob/6ba3207643fd27ffa25a172911e3d6825814d155/pkgs/data/fonts/nerdfonts/shas.nix
};
2023-11-12 21:53:52 +01:00
name = "DejaVuSansM Nerd Font";
};
2023-11-02 21:57:06 +01:00
};
2023-10-29 12:15:56 +01:00
2023-11-20 22:09:28 +01:00
targets = {
2023-11-21 21:01:56 +01:00
i3.enable = false; # I prefer my own styles
tmux.enable = false; # Using another theme
2023-11-20 22:09:28 +01:00
};
2023-10-29 00:49:22 +02:00
};
2023-12-05 23:11:54 +01:00
# Setting a custom base16 theme via nixvim:
# - Is required so nixvim works
# - For the rest only works on dark polarity, use the colorscheme otherwise... shrug
programs.nixvim.colorschemes.base16.colorscheme = "solarized-${polarity}";
2023-10-29 00:49:22 +02:00
# Fix https://nix-community.github.io/home-manager/index.html#_why_do_i_get_an_error_message_about_literal_ca_desrt_dconf_literal_or_literal_dconf_service_literal
# home.packages = [ pkgs.dconf ];
dconf.enable = false; # Otherwise standalone home-manager complains it can't find /etc/dbus-1/session.conf on Arch.
# Symlinking it to /usr/share/dbus-1/session.conf goes further but not much.
2023-12-05 23:11:54 +01:00
home.packages = map
(phase: (pkgs.writeShellApplication {
name = "${phase.command}";
2023-12-16 22:39:11 +01:00
runtimeInputs = [ pkgs.brightnessctl ];
2023-12-05 23:11:54 +01:00
text = (lib.optionalString cfg.enable ''
2023-12-16 22:39:11 +01:00
brightnessctl set ${builtins.getAttr phase.command cfg}
'') + ''
2023-12-05 23:11:54 +01:00
echo ${phase.polarity} > ${polarityFile}
if command -v home-manager
then
home-manager switch
else
# In two steps to get the visual changes slightly earlier
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration test
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration boot
2023-12-05 23:11:54 +01:00
fi
'';
})
)
phases;
2023-10-29 00:49:22 +02:00
}