style: Split out and fixes

This commit is contained in:
Geoffrey Frogeye 2024-01-15 19:26:44 +01:00
parent 1b008c1ae8
commit 43e7a5af46
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
13 changed files with 111 additions and 91 deletions

36
hm/brightness/default.nix Normal file
View file

@ -0,0 +1,36 @@
# Light theme during the day, dark theme during the night (not automatic)
{ pkgs, lib, config, ... }:
let
phases = [
{ command = "jour"; polarity = "light"; }
{ command = "crepuscule"; polarity = "dark"; }
{ command = "nuit"; polarity = "dark"; }
];
phasesBrightness = config.frogeye.desktop.phasesBrightness;
in
{
config = {
home.packages = map
(phase: (pkgs.writeShellApplication {
name = "${phase.command}";
runtimeInputs = [ pkgs.brightnessctl ];
text = (lib.optionalString phasesBrightness.enable ''
brightnessctl set ${builtins.getAttr phase.command phasesBrightness}
'') + ''
switch="/nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration"
if [ -x "$switch" ]
then
# In two steps to get the visual changes slightly earlier
sudo "$switch" test
sudo "$switch" boot
fi
'';
})
)
phases;
xsession.windowManager.i3.config.keybindings = {
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
};
};
}

View file

@ -2,6 +2,7 @@
{ {
imports = [ imports = [
../options.nix ../options.nix
./brightness
./common.nix ./common.nix
./desktop ./desktop
./dev ./dev
@ -18,7 +19,7 @@
./rebuild ./rebuild
./shell ./shell
./ssh.nix ./ssh.nix
./style.nix ./theme
./tmux ./tmux
./usernix ./usernix
./vim ./vim

View file

@ -0,0 +1,13 @@
{ pkgs, config, lib, ... }:
{
config = lib.mkIf config.frogeye.desktop.xorg {
stylix.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";
};
# This correctly sets the background on some occasions, below does the rest
programs.autorandr.hooks.postswitch = {
background = "${pkgs.feh}/bin/feh --no-fehbg --bg-fill ${config.stylix.image}";
};
};
}

View file

@ -7,12 +7,14 @@ in
imports = [ imports = [
./audio ./audio
./autorandr ./autorandr
./background
./frobar ./frobar
./i3.nix ./i3.nix
./lock ./lock
./mpd ./mpd
./presentation ./presentation
./qutebrowser.nix ./qutebrowser.nix
./redness
./screenshots ./screenshots
]; ];
config = lib.mkIf config.frogeye.desktop.xorg { config = lib.mkIf config.frogeye.desktop.xorg {

View file

@ -62,9 +62,6 @@ in
}"; }";
"${mod}+Shift+Return" = "exec ${config.programs.urxvt.package}/bin/urxvt"; "${mod}+Shift+Return" = "exec ${config.programs.urxvt.package}/bin/urxvt";
"${mod}+p" = "exec ${pkgs.xfce.thunar}/bin/thunar"; "${mod}+p" = "exec ${pkgs.xfce.thunar}/bin/thunar";
# Backlight
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
# Misc # Misc
"${mod}+F10" = "exec ${ pkgs.writeShellScript "show-keyboard-layout" "${mod}+F10" = "exec ${ pkgs.writeShellScript "show-keyboard-layout"
'' ''
@ -214,17 +211,6 @@ in
}; };
mod_enter = "Escape"; mod_enter = "Escape";
}; };
"Temperature [R] Red [D] Dust storm [C] Campfire [O] Normal [A] All nighter [B] Blue" = {
bindings = {
"r" = "exec ${pkgs.sct}/bin/sct 1000";
"d" = "exec ${pkgs.sct}/bin/sct 2000";
"c" = "exec ${pkgs.sct}/bin/sct 4500";
"o" = "exec ${pkgs.sct}/bin/sct";
"a" = "exec ${pkgs.sct}/bin/sct 8000";
"b" = "exec ${pkgs.sct}/bin/sct 10000";
};
mod_enter = "y";
};
}; };
}; };
options = { options = {

View file

@ -0,0 +1,28 @@
{ pkgs, lib, config, ... }:
let
# UPST
sct = pkgs.sct.overrideAttrs
(old: {
patches = (old.patches or [ ]) ++ [
./sct_aarch64.patch
];
});
in
{
config = lib.mkIf config.frogeye.desktop.xorg {
frogeye.desktop.i3.bindmodes = {
"Temperature [R] Red [D] Dust storm [C] Campfire [O] Normal [A] All nighter [B] Blue" = {
bindings = {
"r" = "exec ${sct}/bin/sct 1000";
"d" = "exec ${sct}/bin/sct 2000";
"c" = "exec ${sct}/bin/sct 4500";
"o" = "exec ${sct}/bin/sct";
"a" = "exec ${sct}/bin/sct 8000";
"b" = "exec ${sct}/bin/sct 10000";
};
mod_enter = "y";
};
};
home.packages = [ sct ];
};
}

View file

@ -1,59 +0,0 @@
{ pkgs, config, lib, ... }:
let
# Currently last commit in https://github.com/danth/stylix/pull/194
phases = [
{ command = "jour"; polarity = "light"; }
{ command = "crepuscule"; polarity = "dark"; }
{ command = "nuit"; polarity = "dark"; }
];
cfg = config.frogeye.desktop.phasesBrightness;
in
{
stylix = {
base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-${config.frogeye.polarity}.yaml";
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
fonts = {
monospace = {
package = pkgs.nerdfonts.override {
fonts = [ "DejaVuSansMono" ]; # Choose from https://github.com/NixOS/nixpkgs/blob/6ba3207643fd27ffa25a172911e3d6825814d155/pkgs/data/fonts/nerdfonts/shas.nix
};
name = "DejaVuSansM Nerd Font";
};
};
};
programs.autorandr.hooks.postswitch = {
background = "${pkgs.feh}/bin/feh --no-fehbg --bg-fill ${config.stylix.image}";
};
# 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.
home.packages = map
(phase: (pkgs.writeShellApplication {
name = "${phase.command}";
runtimeInputs = [ pkgs.brightnessctl ];
text = (lib.optionalString cfg.enable ''
brightnessctl set ${builtins.getAttr phase.command cfg}
'') + ''
switch="/nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration"
if [ -x "$switch" ]
then
# In two steps to get the visual changes slightly earlier
sudo "$switch" test
sudo "$switch" boot
fi
'';
})
)
phases;
}

24
hm/theme/default.nix Normal file
View file

@ -0,0 +1,24 @@
{ pkgs, config, lib, ... }:
let
basetheme = "solarized";
in
{
config = {
# Setting a custom base16 theme via nixvim is required so feline works, and
# because stylix makes a config that otherwise only works with dark
# polarity.
programs.nixvim.colorschemes.base16.colorscheme = "${basetheme}-${config.frogeye.polarity}";
stylix = {
base16Scheme = "${pkgs.base16-schemes}/share/themes/${basetheme}-${config.frogeye.polarity}.yaml";
fonts = {
monospace = {
package = pkgs.nerdfonts.override {
fonts = [ "DejaVuSansMono" ]; # Choose from https://github.com/NixOS/nixpkgs/blob/6ba3207643fd27ffa25a172911e3d6825814d155/pkgs/data/fonts/nerdfonts/shas.nix
};
name = "DejaVuSansM Nerd Font";
};
};
};
};
}

View file

@ -5,6 +5,10 @@ let
in in
{ {
config = lib.mkIf config.frogeye.userNix { config = lib.mkIf config.frogeye.userNix {
dconf.enable = lib.mkForce false;
# Otherwise standalone home-manager complains it can't find /etc/dbus-1/session.conf.
# Symlinking it to /usr/share/dbus-1/session.conf goes further but not much.
home.activation = { home.activation = {
# When Nix is installed in the user directory via a proot, systemd --user # When Nix is installed in the user directory via a proot, systemd --user
# is started outside of it, so it cannot access /nix. So we need to: # is started outside of it, so it cannot access /nix. So we need to:

View file

@ -12,10 +12,6 @@
vim = "nvim"; vim = "nvim";
}; };
programs.nixvim = { programs.nixvim = {
# Setting a custom base16 theme via nixvim is required so feline works, and
# because stylix makes a config that otherwise only works with dark
# polarity.
colorschemes.base16.colorscheme = "solarized-${config.frogeye.polarity}";
options = { options = {
ignorecase = true; ignorecase = true;
smartcase = true; smartcase = true;

View file

@ -41,18 +41,5 @@
pulseaudio.enable = true; pulseaudio.enable = true;
# TODO Try pipewire # TODO Try pipewire
}; };
# UPST
# TODO Find a way to override packages either at NixOS level or HM level depending on what is used
nixpkgs.overlays = [
(final: prev: {
sct = prev.sct.overrideAttrs
(old: {
patches = (old.patches or [ ]) ++ [
./sct_aarch64.patch
];
});
})
];
}; };
} }

View file

@ -35,6 +35,8 @@
light.configuration.frogeye.polarity = "light"; light.configuration.frogeye.polarity = "light";
}; };
# 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
programs.dconf.enable = true;
# Because everything is encrypted and I'm the only user, this is fine. # Because everything is encrypted and I'm the only user, this is fine.
services.xserver.displayManager.autoLogin.user = "geoffrey"; services.xserver.displayManager.autoLogin.user = "geoffrey";