diff options
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r-- | nixos/modules/programs/light.nix | 50 | ||||
-rw-r--r-- | nixos/modules/programs/ssh.nix | 1 | ||||
-rw-r--r-- | nixos/modules/programs/starship.nix | 33 | ||||
-rw-r--r-- | nixos/modules/programs/wayland/hyprland.nix (renamed from nixos/modules/programs/hyprland.nix) | 0 |
4 files changed, 76 insertions, 8 deletions
diff --git a/nixos/modules/programs/light.nix b/nixos/modules/programs/light.nix index 57cc925be465..1cdf22a7699d 100644 --- a/nixos/modules/programs/light.nix +++ b/nixos/modules/programs/light.nix @@ -9,6 +9,7 @@ in { options = { programs.light = { + enable = mkOption { default = false; type = types.bool; @@ -17,11 +18,60 @@ in and udev rules granting access to members of the "video" group. ''; }; + + brightnessKeys = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable brightness control with keyboard keys. + + This is mainly useful for minimalistic (desktop) environments. You + may want to leave this disabled if you run a feature-rich desktop + environment such as KDE, GNOME or Xfce as those handle the + brightness keys themselves. However, enabling brightness control + with this setting makes the control independent of X, so the keys + work in non-graphical ttys, so you might want to consider using this + instead of the default offered by the desktop environment. + + Enabling this will turn on {option}`services.actkbd`. + ''; + }; + + step = mkOption { + type = types.int; + default = 10; + description = '' + The percentage value by which to increase/decrease brightness. + ''; + }; + + }; + }; }; config = mkIf cfg.enable { environment.systemPackages = [ pkgs.light ]; services.udev.packages = [ pkgs.light ]; + services.actkbd = mkIf cfg.brightnessKeys.enable { + enable = true; + bindings = let + light = "${pkgs.light}/bin/light"; + step = toString cfg.brightnessKeys.step; + in [ + { + keys = [ 224 ]; + events = [ "key" ]; + # Use minimum brightness 0.1 so the display won't go totally black. + command = "${light} -N 0.1 && ${light} -U ${step}"; + } + { + keys = [ 225 ]; + events = [ "key" ]; + command = "${light} -A ${step}"; + } + ]; + }; }; } diff --git a/nixos/modules/programs/ssh.nix b/nixos/modules/programs/ssh.nix index c39a3c8d509b..0c1461709c22 100644 --- a/nixos/modules/programs/ssh.nix +++ b/nixos/modules/programs/ssh.nix @@ -12,6 +12,7 @@ let '' #! ${pkgs.runtimeShell} -e export DISPLAY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^DISPLAY=\(.*\)/\1/; t; d')" + export XAUTHORITY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^XAUTHORITY=\(.*\)/\1/; t; d')" export WAYLAND_DISPLAY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^WAYLAND_DISPLAY=\(.*\)/\1/; t; d')" exec ${cfg.askPassword} "$@" ''; diff --git a/nixos/modules/programs/starship.nix b/nixos/modules/programs/starship.nix index bec3900496fd..34f6f0882c61 100644 --- a/nixos/modules/programs/starship.nix +++ b/nixos/modules/programs/starship.nix @@ -1,13 +1,21 @@ { config, lib, pkgs, ... }: -with lib; - let cfg = config.programs.starship; settingsFormat = pkgs.formats.toml { }; - settingsFile = settingsFormat.generate "starship.toml" cfg.settings; + userSettingsFile = settingsFormat.generate "starship.toml" cfg.settings; + + settingsFile = if cfg.presets == [] then userSettingsFile else pkgs.runCommand "starship.toml" + { + nativeBuildInputs = [ pkgs.yq ]; + } '' + tomlq -s -t 'reduce .[] as $item ({}; . * $item)' \ + ${lib.concatStringsSep " " (map (f: "${pkgs.starship}/share/starship/presets/${f}.toml") cfg.presets)} \ + ${userSettingsFile} \ + > $out + ''; initOption = if cfg.interactiveOnly then @@ -18,19 +26,28 @@ let in { options.programs.starship = { - enable = mkEnableOption (lib.mdDoc "the Starship shell prompt"); + enable = lib.mkEnableOption (lib.mdDoc "the Starship shell prompt"); - interactiveOnly = mkOption { + interactiveOnly = lib.mkOption { default = true; example = false; - type = types.bool; + type = lib.types.bool; description = lib.mdDoc '' Whether to enable starship only when the shell is interactive. Some plugins require this to be set to false to function correctly. ''; }; - settings = mkOption { + presets = lib.mkOption { + default = [ ]; + example = [ "nerd-font-symbols" ]; + type = with lib.types; listOf str; + description = lib.mdDoc '' + Presets files to be merged with settings in order. + ''; + }; + + settings = lib.mkOption { inherit (settingsFormat) type; default = { }; description = lib.mdDoc '' @@ -41,7 +58,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { programs.bash.${initOption} = '' if [[ $TERM != "dumb" ]]; then # don't set STARSHIP_CONFIG automatically if there's a user-specified diff --git a/nixos/modules/programs/hyprland.nix b/nixos/modules/programs/wayland/hyprland.nix index 9061ce5da83a..9061ce5da83a 100644 --- a/nixos/modules/programs/hyprland.nix +++ b/nixos/modules/programs/wayland/hyprland.nix |