From 43e7a5af46936ec9231e7ed977ef18bf1bc2ab90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 15 Jan 2024 19:26:44 +0100 Subject: [PATCH] style: Split out and fixes --- hm/brightness/default.nix | 36 ++++++++++++ hm/default.nix | 3 +- hm/desktop/background/default.nix | 13 +++++ hm/desktop/default.nix | 2 + hm/desktop/i3.nix | 14 ----- hm/desktop/redness/default.nix | 28 ++++++++++ {os => hm/desktop/redness}/sct_aarch64.patch | 0 hm/style.nix | 59 -------------------- hm/theme/default.nix | 24 ++++++++ hm/usernix/default.nix | 4 ++ hm/vim/default.nix | 4 -- os/desktop.nix | 13 ----- os/geoffrey.nix | 2 + 13 files changed, 111 insertions(+), 91 deletions(-) create mode 100644 hm/brightness/default.nix create mode 100644 hm/desktop/background/default.nix create mode 100644 hm/desktop/redness/default.nix rename {os => hm/desktop/redness}/sct_aarch64.patch (100%) delete mode 100644 hm/style.nix create mode 100644 hm/theme/default.nix diff --git a/hm/brightness/default.nix b/hm/brightness/default.nix new file mode 100644 index 0000000..8fbc60e --- /dev/null +++ b/hm/brightness/default.nix @@ -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%-"; + }; + }; +} diff --git a/hm/default.nix b/hm/default.nix index 85789fa..9f28122 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -2,6 +2,7 @@ { imports = [ ../options.nix + ./brightness ./common.nix ./desktop ./dev @@ -18,7 +19,7 @@ ./rebuild ./shell ./ssh.nix - ./style.nix + ./theme ./tmux ./usernix ./vim diff --git a/hm/desktop/background/default.nix b/hm/desktop/background/default.nix new file mode 100644 index 0000000..78054f6 --- /dev/null +++ b/hm/desktop/background/default.nix @@ -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}"; + }; + }; +} diff --git a/hm/desktop/default.nix b/hm/desktop/default.nix index 6241af0..d02582b 100644 --- a/hm/desktop/default.nix +++ b/hm/desktop/default.nix @@ -7,12 +7,14 @@ in imports = [ ./audio ./autorandr + ./background ./frobar ./i3.nix ./lock ./mpd ./presentation ./qutebrowser.nix + ./redness ./screenshots ]; config = lib.mkIf config.frogeye.desktop.xorg { diff --git a/hm/desktop/i3.nix b/hm/desktop/i3.nix index 482a1cd..de153d7 100644 --- a/hm/desktop/i3.nix +++ b/hm/desktop/i3.nix @@ -62,9 +62,6 @@ in }"; "${mod}+Shift+Return" = "exec ${config.programs.urxvt.package}/bin/urxvt"; "${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 "${mod}+F10" = "exec ${ pkgs.writeShellScript "show-keyboard-layout" '' @@ -214,17 +211,6 @@ in }; 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 = { diff --git a/hm/desktop/redness/default.nix b/hm/desktop/redness/default.nix new file mode 100644 index 0000000..339684c --- /dev/null +++ b/hm/desktop/redness/default.nix @@ -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 ]; + }; +} diff --git a/os/sct_aarch64.patch b/hm/desktop/redness/sct_aarch64.patch similarity index 100% rename from os/sct_aarch64.patch rename to hm/desktop/redness/sct_aarch64.patch diff --git a/hm/style.nix b/hm/style.nix deleted file mode 100644 index c758b79..0000000 --- a/hm/style.nix +++ /dev/null @@ -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; -} diff --git a/hm/theme/default.nix b/hm/theme/default.nix new file mode 100644 index 0000000..e9122f4 --- /dev/null +++ b/hm/theme/default.nix @@ -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"; + }; + }; + }; + }; +} diff --git a/hm/usernix/default.nix b/hm/usernix/default.nix index 84243cc..8ea05f1 100644 --- a/hm/usernix/default.nix +++ b/hm/usernix/default.nix @@ -5,6 +5,10 @@ let in { 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 = { # 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: diff --git a/hm/vim/default.nix b/hm/vim/default.nix index 1ac8b81..7effdf5 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -12,10 +12,6 @@ vim = "nvim"; }; 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 = { ignorecase = true; smartcase = true; diff --git a/os/desktop.nix b/os/desktop.nix index 24e4dc1..d836976 100644 --- a/os/desktop.nix +++ b/os/desktop.nix @@ -41,18 +41,5 @@ pulseaudio.enable = true; # 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 - ]; - }); - }) - ]; }; } diff --git a/os/geoffrey.nix b/os/geoffrey.nix index 4b3833c..7a1e78b 100644 --- a/os/geoffrey.nix +++ b/os/geoffrey.nix @@ -35,6 +35,8 @@ 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. services.xserver.displayManager.autoLogin.user = "geoffrey";