From 0ce061fa31c988005a97ddb557930cf38fcaaea5 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 5 Jul 2024 00:41:59 +0200 Subject: [PATCH] switch to getExe and getExe' throughout the config --- hosts/chmura/services/anki-sync-server.nix | 7 +++-- hosts/del/configuration.nix | 23 ++++++++------ hosts/del/waybar.nix | 36 +++++++++++++++------- hosts/niks/configuration.nix | 13 +++++--- hosts/niks/waybar.nix | 18 ++++++++--- modules/cli/git.nix | 8 +++-- modules/gui/foot.nix | 11 ++++--- modules/gui/hypr/idle.nix | 6 ++-- modules/gui/hypr/land.nix | 9 +++--- modules/services/anki-sync-server.nix | 4 +-- modules/services/dunst.nix | 8 +++-- modules/services/greetd.nix | 13 +++++--- modules/services/ssh.nix | 9 ++++-- modules/tui/helix.nix | 9 ++++-- options/desktop/power-supply.nix | 26 ++++++++++------ options/desktop/suspend.nix | 18 ++++++++--- 16 files changed, 144 insertions(+), 74 deletions(-) diff --git a/hosts/chmura/services/anki-sync-server.nix b/hosts/chmura/services/anki-sync-server.nix index 229f6af..f35d042 100644 --- a/hosts/chmura/services/anki-sync-server.nix +++ b/hosts/chmura/services/anki-sync-server.nix @@ -1,8 +1,11 @@ { config, + lib, pkgs, ... -}: { +}: let + inherit (lib) getExe'; +in { age.secrets.anki-user-credentials.file = ../../../secrets/anki-user-credentials.age; systemd.services.anki-sync-server = { @@ -14,7 +17,7 @@ Type = "simple"; DynamicUser = true; StateDirectory = "anki-sync-server"; - ExecStart = "${pkgs.anki-bin}/bin/anki --syncserver"; + ExecStart = "${getExe' pkgs.anki-bin "anki"} --syncserver"; Environment = ''SYNC_BASE="/var/lib/anki-sync-server" SYNC_HOST="127.0.0.1" SYNC_PORT="27701"''; EnvironmentFile = config.age.secrets.anki-user-credentials.path; Restart = "always"; diff --git a/hosts/del/configuration.nix b/hosts/del/configuration.nix index c7c5f21..73095d8 100644 --- a/hosts/del/configuration.nix +++ b/hosts/del/configuration.nix @@ -4,7 +4,9 @@ lib, pkgs, ... -}: { +}: let + inherit (lib) getExe getExe'; +in { nixpkgs.config.allowUnfree = true; nix.settings = { @@ -34,7 +36,7 @@ }; environment.sessionVariables = { - CHROME_EXECUTABLE = "${pkgs.ungoogled-chromium}/bin/chromium"; + CHROME_EXECUTABLE = getExe pkgs.ungoogled-chromium; }; hardware = { @@ -181,7 +183,7 @@ extraSettings = let inherit (config.myOptions.other.system) username; hmCfg = config.home-manager.users.${username}; - inherit (inputs.nixpkgs-wayland.packages.${pkgs.system}) swww; + swww = getExe inputs.nixpkgs-wayland.packages.${pkgs.system}.swww; nix_wallpaper = pkgs.fetchurl { url = "https://i.ibb.co/vZ5JF95/nix-Wallpaper.png"; hash = "sha256-BqOBvRFXFrX/QLI70OLAIcpbbiUH/jUMK97yqCfY+mI="; @@ -191,18 +193,21 @@ out_dir = "${hmCfg.xdg.dataHome}/hypr"; out_path = "${out_dir}/nix.png"; - iio-hyprland = inputs.iio-hyprland.packages.${pkgs.system}.default; + iio-hyprland = getExe inputs.iio-hyprland.packages.${pkgs.system}.default; + + mkdir = getExe' pkgs.coreutils-full "mkdir"; + sleep = getExe' pkgs.coreutils-full "sleep"; in { exec-once = [ - "${iio-hyprland}/bin/iio-hyprland" - "${pkgs.wvkbd}/bin/wvkbd-mobintl --hidden -L 500" + "${iio-hyprland}" + "${getExe pkgs.wvkbd} --hidden -L 500" - "${pkgs.coreutils-full}/bin/mkdir -p ${out_dir}" - "${pkgs.imagemagick}/bin/magick ${nix_wallpaper} ${poz_layer} -layers flatten ${out_path}" + "${mkdir} -p ${out_dir}" + "${getExe pkgs.imagemagick} ${nix_wallpaper} ${poz_layer} -layers flatten ${out_path}" ]; exec = [ # wait a bit then set the wallpapers - "sleep 0.5 && ${swww}/bin/swww img -o eDP-1 ${out_path}" + "${sleep} 0.5 && ${swww} img -o eDP-1 ${out_path}" ]; }; }; diff --git a/hosts/del/waybar.nix b/hosts/del/waybar.nix index 5785033..0709201 100644 --- a/hosts/del/waybar.nix +++ b/hosts/del/waybar.nix @@ -1,12 +1,26 @@ { config, inputs, + lib, pkgs, ... }: let inherit (config.myOptions.other.system) username; - iio-hyprland = inputs.iio-hyprland.packages.${pkgs.system}.default; + inherit (lib) getExe getExe'; + + iio-hyprland = getExe inputs.iio-hyprland.packages.${pkgs.system}.default; + wpctl = getExe' pkgs.wireplumber "wpctl"; + brightnessctl = getExe pkgs.brightnessctl; + inherit (inputs.hyprland.packages.${pkgs.system}) hyprland; + hyprctl = getExe' hyprland "hyprctl"; + rg = getExe pkgs.ripgrep; + wc = getExe' pkgs.coreutils-full "wc"; + kill = getExe' pkgs.util-linux "kill"; + pkill = getExe' pkgs.procps "pkill"; + pidof = getExe' pkgs.procps "pidof"; + asusctl = getExe' config.services.asusd.package "asusctl"; + sed = getExe pkgs.gnused; in { home-manager.users.${username} = { programs.waybar = { @@ -27,7 +41,7 @@ in { format-icons = { default = ["󰕿" "󰖀" "󰕾"]; }; - on-click = "${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + on-click = "${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle"; }; "hyprland/workspaces" = { sort-by-name = true; @@ -78,8 +92,8 @@ in { format-icons = [ "󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠" ]; #on-scroll-up = "~/Scripts/bright.sh s +1%"; #on-scroll-down = "~/Scripts/bright.sh s 1%-"; - on-scroll-up = "${pkgs.brightnessctl}/bin/brightnessctl set +1%"; - on-scroll-down = "${pkgs.brightnessctl}/bin/brightnessctl set 1%-"; + on-scroll-up = "${brightnessctl} set +1%"; + on-scroll-down = "${brightnessctl} set 1%-"; smooth-scrolling-threshold = 1; }; battery = { @@ -139,7 +153,7 @@ in { "custom/launcher" = { format = " "; on-click = "~/.config/rofi/launchers/type-2/launcher.sh"; - on-click-right = "pkill rofi"; + on-click-right = "${pkill} rofi"; }; "custom/power" = { format = "󰐥"; @@ -189,28 +203,28 @@ in { }; }; "custom/power_profile" = { - exec = "asusctl profile -p | sed s:'Active profile is'::"; + exec = "${asusctl} profile -p | ${sed} s:'Active profile is'::"; interval = 30; format = "󰈐{}"; format-alt-click = "click-right"; format-alt = "󰈐"; - on-click = "asusctl profile -n; pkill -SIGRTMIN+8 waybar"; + on-click = "${asusctl} profile -n; ${pkill} -SIGRTMIN+8 waybar"; signal = 8; }; "custom/xwayland" = { - exec = "${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl clients | ${pkgs.ripgrep}/bin/rg -e 'xwayland: [1]' | ${pkgs.coreutils-full}/bin/wc -l"; + exec = "${hyprctl} clients | ${rg} -e 'xwayland: [1]' | ${wc} -l"; interval = 1; format = "X {}"; }; "custom/rot" = { - exec = "${pkgs.procps}/bin/pidof iio-hyprland > /dev/null; if [ $? -eq '0' ]; then echo -n '󰿆'; else echo -n '󰌾'; fi"; + exec = "${pidof} iio-hyprland > /dev/null; if [ $? -eq '0' ]; then echo -n '󰿆'; else echo -n '󰌾'; fi"; interval = 1; - on-click = "${pkgs.procps}/bin/pkill iio-hyprland || ${iio-hyprland}/bin/iio-hyprland & disown"; + on-click = "${pkill} iio-hyprland || ${iio-hyprland} & disown"; format = "󰑤 {}"; }; "custom/wvkbd" = { # RTMIN - on-click = "${pkgs.util-linux}/bin/kill -s 34 $(${pkgs.procps}/bin/pidof wvkbd-mobintl)"; + on-click = "${kill} -s 34 $(${pidof} wvkbd-mobintl)"; format = "󰌌"; }; mpd = { diff --git a/hosts/niks/configuration.nix b/hosts/niks/configuration.nix index 2b68f0e..8d758c6 100644 --- a/hosts/niks/configuration.nix +++ b/hosts/niks/configuration.nix @@ -1,9 +1,12 @@ { config, inputs, + lib, pkgs, ... -}: { +}: let + inherit (lib) getExe; +in { nixpkgs.config = { permittedInsecurePackages = [ "python-2.7.18.6" @@ -34,7 +37,7 @@ security.polkit.enable = true; environment.sessionVariables = { - CHROME_EXECUTABLE = "${pkgs.ungoogled-chromium}/bin/chromium"; + CHROME_EXECUTABLE = getExe pkgs.ungoogled-chromium; }; services = { @@ -127,11 +130,11 @@ ]; extraSettings = { exec = let - inherit (inputs.nixpkgs-wayland.packages.${pkgs.system}) swww; + swww = getExe inputs.nixpkgs-wayland.packages.${pkgs.system}.swww; in [ # wait a bit then set the wallpapers - "sleep 0.5 && ${swww}/bin/swww img -o eDP-1 ${./catppuccin-wall0.png}" - "sleep 0.5 && ${swww}/bin/swww img -o HDMI-A-1 ${./catppuccin-wall1.png}" + "sleep 0.5 && ${swww} img -o eDP-1 ${./catppuccin-wall0.png}" + "sleep 0.5 && ${swww} img -o HDMI-A-1 ${./catppuccin-wall1.png}" ]; }; }; diff --git a/hosts/niks/waybar.nix b/hosts/niks/waybar.nix index ba0a259..ffaa177 100644 --- a/hosts/niks/waybar.nix +++ b/hosts/niks/waybar.nix @@ -1,10 +1,20 @@ { config, inputs, + lib, pkgs, ... }: let inherit (config.myOptions.other.system) username; + + inherit (lib) getExe getExe'; + + wpctl = getExe' pkgs.wireplumber "wpctl"; + brightnessctl = getExe pkgs.brightnessctl; + inherit (inputs.hyprland.packages.${pkgs.system}) hyprland; + hyprctl = getExe' hyprland "hyprctl"; + rg = getExe pkgs.ripgrep; + wc = getExe' pkgs.coreutils-full "wc"; in { home-manager.users.${username} = { programs.waybar = { @@ -25,7 +35,7 @@ in { format-icons = { default = ["󰕿" "󰖀" "󰕾"]; }; - on-click = "${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + on-click = "${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle"; }; "hyprland/workspaces" = { sort-by-name = true; @@ -76,8 +86,8 @@ in { format-icons = [ "󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠" ]; #on-scroll-up = "~/Scripts/bright.sh s +1%"; #on-scroll-down = "~/Scripts/bright.sh s 1%-"; - on-scroll-up = "${pkgs.brightnessctl}/bin/brightnessctl set +1%"; - on-scroll-down = "${pkgs.brightnessctl}/bin/brightnessctl set 1%-"; + on-scroll-up = "${brightnessctl} set +1%"; + on-scroll-down = "${brightnessctl} set 1%-"; smooth-scrolling-threshold = 1; }; battery = { @@ -196,7 +206,7 @@ in { signal = 8; }; "custom/xwayland" = { - exec = "${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl clients | ${pkgs.ripgrep}/bin/rg -e 'xwayland: [1]' | ${pkgs.coreutils-full}/bin/wc -l"; + exec = "${hyprctl} clients | ${rg} -e 'xwayland: [1]' | ${wc} -l"; interval = 1; format = "X {}"; }; diff --git a/modules/cli/git.nix b/modules/cli/git.nix index bdc0302..d8fe341 100644 --- a/modules/cli/git.nix +++ b/modules/cli/git.nix @@ -7,8 +7,10 @@ cfg = config.myOptions.programs.git; inherit (config.myOptions.other.system) username; - inherit (lib) mkEnableOption mkIf mkOption; + inherit (lib) getExe mkEnableOption mkIf mkOption; inherit (lib.types) nullOr str; + + delta = getExe pkgs.delta; in { options.myOptions.programs.git = { enable = mkEnableOption "git"; @@ -47,7 +49,7 @@ in { extraConfig = { core = { inherit (cfg) editor; - pager = "${pkgs.delta}/bin/delta"; + pager = "${delta}"; }; init.defaultBranch = cfg.defaultBranch; push.autoSetupRemote = true; @@ -58,7 +60,7 @@ in { gpg.format = "ssh"; user.signingkey = mkIf (cfg.signingKey != null) "key::${cfg.signingKey}"; merge.conflictstyle = "zdiff3"; - interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only"; + interactive.diffFilter = "${delta} --color-only"; diff.algorithm = "histogram"; transfer.fsckobjects = true; fetch.fsckobjects = true; diff --git a/modules/gui/foot.nix b/modules/gui/foot.nix index ce14974..a5604b5 100644 --- a/modules/gui/foot.nix +++ b/modules/gui/foot.nix @@ -8,7 +8,10 @@ cfg = config.myOptions.programs.foot; inherit (config.myOptions.other.system) username; - inherit (lib) mkEnableOption mkIf; + inherit (lib) getExe getExe' mkEnableOption mkIf; + + notify-send = getExe pkgs.libnotify; + xdg-open = getExe' pkgs.xdg-utils "xdg-open"; in { options.myOptions.programs.foot = { enable = mkEnableOption "foot"; @@ -44,7 +47,7 @@ in { pad = "5x5 center"; resize-delay-ms = 100; - notify = "${pkgs.libnotify}/bin/notify-send -a \${app-id} -i \${app-id} \${title} \${body}"; + notify = "${notify-send} -a \${app-id} -i \${app-id} \${title} \${body}"; bold-text-in-bright = "no"; word-delimiters = ",│`|:\"'()[]{}<>"; @@ -53,7 +56,7 @@ in { bell = { urgent = "yes"; notify = "yes"; - command = "${pkgs.libnotify}/bin/notify-send bell"; + command = "${notify-send} bell"; command-focused = "no"; }; scrollback = { @@ -63,7 +66,7 @@ in { indicator-format = "line"; }; url = { - launch = "${pkgs.xdg-utils}/bin/xdg-open \${url}"; + launch = "${xdg-open} \${url}"; label-letters = "sadfjklewcmpgh"; osc8-underline = "always"; protocols = "http, https, ftp, ftps, file, gemini, gopher, irc, ircs"; diff --git a/modules/gui/hypr/idle.nix b/modules/gui/hypr/idle.nix index fa64f7e..1c949b9 100644 --- a/modules/gui/hypr/idle.nix +++ b/modules/gui/hypr/idle.nix @@ -9,7 +9,9 @@ hmCfg = config.home-manager.users.${username}; inherit (config.myOptions.other.system) username; - inherit (lib) mkEnableOption mkIf; + inherit (lib) getExe' mkEnableOption mkIf; + + loginctl = getExe' pkgs.systemd "loginctl"; in { options.myOptions.programs.hypr.idle = { enable = mkEnableOption "hiper bezczynny"; @@ -23,7 +25,7 @@ in { settings = { general = { lock_cmd = lib.getExe hmCfg.programs.hyprlock.package; - before_sleep_cmd = "${pkgs.systemd}/bin/loginctl lock-session"; + before_sleep_cmd = "${loginctl} lock-session"; }; }; }; diff --git a/modules/gui/hypr/land.nix b/modules/gui/hypr/land.nix index 5a5f9b1..b54ab09 100644 --- a/modules/gui/hypr/land.nix +++ b/modules/gui/hypr/land.nix @@ -40,6 +40,7 @@ pkill = getExe' pkgs.procps "pkill"; tee = getExe' pkgs.coreutils-full "tee"; + sleep = getExe' pkgs.coreutils-full "sleep"; xdg-user-dir = getExe' pkgs.xdg-user-dirs "xdg-user-dir"; xdg-open = getExe' pkgs.xdg-utils "xdg-open"; notify-send = getExe pkgs.libnotify; @@ -60,7 +61,7 @@ pamixer = getExe pkgs.pamixer; brightnessctl = getExe pkgs.brightnessctl; rg = getExe pkgs.ripgrep; - gawk = getExe pkgs.gawk; + awk = getExe pkgs.gawk; mpv = getExe pkgs.mpv; in { options.myOptions.programs.hypr.land = { @@ -408,8 +409,8 @@ in { "$mainMod SHIFT, G, changegroupactive, f" "$mainMod CONTROL, G, changegroupactive, b" - "$mainMod, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${gawk} '{print $2 + 0.05}')\"" - "$mainMod, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${gawk} '{if($2 != 1) {print $2 - 0.05}}')\"" + "$mainMod, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${awk} '{print $2 + 0.05}')\"" + "$mainMod, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${awk} '{if($2 != 1) {print $2 - 0.05}}')\"" ]; # locked @@ -488,7 +489,7 @@ in { (mkIf config.services.asusd.enable "[workspace special:rog silent;tile] ${rog-control-center}") "[workspace special:keepassxc silent;tile] ${keepassxc}" - (mkIf config.myOptions.programs.foot.server "sleep 0.5 && ${systemctl} --user restart foot.service") + (mkIf config.myOptions.programs.foot.server "${sleep} 0.5 && ${systemctl} --user restart foot.service") "${hyprctl} setcursor Bibata-Modern-Classic 24" diff --git a/modules/services/anki-sync-server.nix b/modules/services/anki-sync-server.nix index ee9b18b..0c19df8 100644 --- a/modules/services/anki-sync-server.nix +++ b/modules/services/anki-sync-server.nix @@ -6,7 +6,7 @@ }: let cfg = config.services.anki-sync-server; - inherit (lib) mkEnableOption mkIf mkOption; + inherit (lib) getExe' mkEnableOption mkIf mkOption; inherit (lib.types) bool package port str; in { options.services.anki-sync-server = { @@ -50,7 +50,7 @@ in { Type = "simple"; DynamicUser = true; StateDirectory = "anki-sync-server"; - ExecStart = "${cfg.package}/bin/anki --syncserver"; + ExecStart = "${getExe' cfg.package "anki"} --syncserver"; Environment = ''SYNC_BASE="/var/lib/anki-sync-server" SYNC_HOST="${cfg.host}" SYNC_PORT="${cfg.port}"''; EnvironmentFile = config.age.secrets.anki-user-credentials.path; Restart = "always"; diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 3a90b6d..19df17a 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -8,7 +8,9 @@ cfg = config.myOptions.services.dunst; inherit (config.myOptions.other.system) username; - inherit (lib) mkEnableOption mkIf; + inherit (lib) getExe getExe' mkEnableOption mkIf; + + xdg-open = getExe' pkgs.xdg-utils "xdg-open"; in { options.myOptions.services.dunst.enable = mkEnableOption "dunst"; @@ -59,8 +61,8 @@ in { max_icon_size = 32; sticky_history = "yes"; history_length = 20; - dmenu = "${pkgs.rofi-wayland}/bin/rofi"; - browser = "${pkgs.xdg-utils}/bin/xdg-open"; + dmenu = "${getExe pkgs.rofi-wayland}"; + browser = "${xdg-open}"; always_run_script = true; title = "Dunst"; class = "dunst"; diff --git a/modules/services/greetd.nix b/modules/services/greetd.nix index 8a16c6b..60e72f9 100644 --- a/modules/services/greetd.nix +++ b/modules/services/greetd.nix @@ -8,12 +8,17 @@ cfg = config.myOptions.services.greetd; inherit (config.myOptions.other.system) username; - inherit (lib) mkEnableOption mkIf mkOption; + inherit (lib) getExe getExe' mkEnableOption mkIf mkOption; inherit (lib.types) listOf str; inherit (lib.strings) concatStringsSep; inherit (inputs.hyprland.packages.${pkgs.system}) hyprland; + hyprctl = getExe' hyprland "hyprctl"; + Hyprland = getExe' hyprland "Hyprland"; + + greeter = getExe pkgs.greetd.${cfg.greeter}; + hyprlandConfig = pkgs.writeText "greetd-hyprland-config" '' misc { force_default_wallpaper=0 @@ -27,8 +32,8 @@ workspace=1,default:true,gapsout:0,gapsin:0,border:false,decorate:false - exec-once=[workspace 1;fullscreen;noanim] ${pkgs.greetd.${cfg.greeter}}/bin/${cfg.greeter} -l; ${hyprland}/bin/hyprctl dispatch exit - exec-once=${hyprland}/bin/hyprctl dispatch focuswindow ${cfg.greeter} + exec-once=[workspace 1;fullscreen;noanim] ${greeter} -l; ${hyprctl} dispatch exit + exec-once=${hyprctl} dispatch focuswindow ${cfg.greeter} ''; in { options.myOptions.services.greetd = { @@ -47,7 +52,7 @@ in { services.greetd = { enable = true; settings.default_session = { - command = "${hyprland}/bin/Hyprland --config ${hyprlandConfig}"; + command = "${Hyprland} --config ${hyprlandConfig}"; user = username; }; }; diff --git a/modules/services/ssh.nix b/modules/services/ssh.nix index 068cfa1..49fddd6 100644 --- a/modules/services/ssh.nix +++ b/modules/services/ssh.nix @@ -6,10 +6,13 @@ }: let cfg = config.myOptions.services.ssh; - inherit (lib) mkEnableOption mkIf mkMerge mkOption; + inherit (lib) getExe' mkEnableOption mkIf mkMerge mkOption; inherit (lib.types) attrsOf bool nullOr number str submodule; inherit (lib.strings) concatStrings; inherit (lib.attrsets) mapAttrsToList; + + ksshaskpass = getExe' pkgs.libsForQt5.ksshaskpass "ksshaskpass"; + ssh-agent = getExe' pkgs.openssh "ssh-agent"; in { options.myOptions.services.ssh = { daemon = mkOption { @@ -81,7 +84,7 @@ in { (mkIf cfg.agent.enable { programs.ssh = { enableAskPassword = true; - askPassword = "${pkgs.libsForQt5.ksshaskpass}/bin/ksshaskpass"; + askPassword = ksshaskpass; extraConfig = '' AddKeysToAgent yes @@ -108,7 +111,7 @@ in { description = "SSH key agent"; serviceConfig = { Type = "simple"; - ExecStart = "${pkgs.openssh}/bin/ssh-agent -D -a $SSH_AUTH_SOCK"; + ExecStart = "${ssh-agent} -D -a $SSH_AUTH_SOCK"; }; environment = { SSH_AUTH_SOCK = "%t/ssh-agent.socket"; diff --git a/modules/tui/helix.nix b/modules/tui/helix.nix index 9fdd257..ef7d572 100644 --- a/modules/tui/helix.nix +++ b/modules/tui/helix.nix @@ -8,7 +8,10 @@ cfg = config.myOptions.programs.helix; inherit (config.myOptions.other.system) username; - inherit (lib) mkEnableOption mkIf; + inherit (lib) getExe getExe' mkEnableOption mkIf; + + clangd = getExe' pkgs.clang-tools "clangd"; + css-languageserver = getExe pkgs.nodePackages.vscode-css-languageserver-bin; in { options.myOptions.programs.helix.enable = mkEnableOption "helix"; @@ -71,11 +74,11 @@ in { config.nil.formatting.command = [ "${lib.getExe pkgs.alejandra}" "-q" ]; }; clangd = { - command = "${pkgs.clang-tools}/bin/clangd"; + command = clangd; clangd.fallbackFlags = [ "-std=c++2b" ]; }; vscode-css-language-server = { - command = "${pkgs.nodePackages.vscode-css-languageserver-bin}/bin/css-languageserver"; + command = css-languageserver; args = [ "--stdio" ]; }; }; diff --git a/options/desktop/power-supply.nix b/options/desktop/power-supply.nix index da113d8..f478b90 100644 --- a/options/desktop/power-supply.nix +++ b/options/desktop/power-supply.nix @@ -1,25 +1,31 @@ { config, inputs, + lib, pkgs, ... }: { services.udev.extraRules = let + inherit (lib) getExe getExe'; + asusctl = getExe' config.services.asusd.package "asusctl"; + supergfxctl = getExe' config.services.asusd.package "supergfxctl"; + cpupower = getExe config.boot.kernelPackages.cpupower; inherit (inputs.hyprland.packages.${pkgs.system}) hyprland; + hyprctl = getExe' hyprland "hyprctl"; power_supply = pkgs.writeShellScript "on_power_supply" '' - ${pkgs.asusctl}/bin/asusctl profile -P Performance - #${pkgs.supergfxctl}/bin/supergfxctl -m Hybrid - ${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g performance - ${hyprland}/bin/hyprctl keyword decoration:blur:enabled true - ${hyprland}/bin/hyprctl keyword animations:enabled true + ${asusctl} profile -P Performance + #${supergfxctl} -m Hybrid + ${cpupower}/bin/cpupower frequency-set -g performance + ${hyprctl} keyword decoration:blur:enabled true + ${hyprctl} keyword animations:enabled true ''; battery = pkgs.writeShellScript "on_battery" '' - ${pkgs.asusctl}/bin/asusctl profile -P Quiet - #${pkgs.supergfxctl}/bin/supergfxctl -m Integrated - ${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g powersave - ${hyprland}/bin/hyprctl keyword decoration:blur:enabled false - ${hyprland}/bin/hyprctl keyword animations:enabled false + ${asusctl} profile -P Quiet + #${supergfxctl} -m Integrated + ${cpupower}/bin/cpupower frequency-set -g powersave + ${hyprctl} keyword decoration:blur:enabled false + ${hyprctl} keyword animations:enabled false ''; in '' SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="1",RUN+="${power_supply}" diff --git a/options/desktop/suspend.nix b/options/desktop/suspend.nix index eeac955..61631b7 100644 --- a/options/desktop/suspend.nix +++ b/options/desktop/suspend.nix @@ -1,17 +1,25 @@ { inputs, + lib, pkgs, ... }: { - powerManagement = { + powerManagement = let + inherit (lib) getExe getExe'; + mpc = getExe pkgs.mpc-cli; + sleep = getExe' pkgs.coreutils-full "sleep"; + + inherit (inputs.hyprland.packages.${pkgs.system}) hyprland; + hyprctl = getExe' hyprland "hyprctl"; + in{ enable = true; powerDownCommands = '' - ${pkgs.mpc-cli}/bin/mpc pause - ${pkgs.coreutils-full}/bin/sleep 1 + ${mpc} pause + ${sleep} 1 ''; powerUpCommands = '' - ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms off HDMI-A-1 - ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms on HDMI-A-1 + ${hyprctl} dispatch dpms off HDMI-A-1 + ${hyprctl} dispatch dpms on HDMI-A-1 ''; }; }