diff --git a/hosts/common/configs/brightnessctl/default.nix b/hosts/common/configs/brightnessctl/default.nix index cc9abf8..bb66554 100644 --- a/hosts/common/configs/brightnessctl/default.nix +++ b/hosts/common/configs/brightnessctl/default.nix @@ -3,10 +3,15 @@ { environment.systemPackages = with pkgs; [ brightnessctl ]; - services.udev.extraRules = '' - ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils-full}/bin/chgrp video /sys/class/backlight/%k/brightness" - ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils-full}/bin/chmod g+w /sys/class/backlight/%k/brightness" - ACTION=="add", SUBSYSTEM=="leds", RUN+="${pkgs.coreutils-full}/bin/chgrp input /sys/class/leds/%k/brightness" - ACTION=="add", SUBSYSTEM=="leds", RUN+="${pkgs.coreutils-full}/bin/chmod g+w /sys/class/leds/%k/brightness" - ''; + services.udev.extraRules = + let + chgrp = "${pkgs.coreutils-full}/bin/chgrp"; + chmod = "${pkgs.coreutils-full}/bin/chmod"; + in + '' + ACTION=="add", SUBSYSTEM=="backlight", RUN+="${chgrp} video /sys/class/backlight/%k/brightness" + ACTION=="add", SUBSYSTEM=="backlight", RUN+="${chmod} g+w /sys/class/backlight/%k/brightness" + ACTION=="add", SUBSYSTEM=="leds", RUN+="${chgrp} input /sys/class/leds/%k/brightness" + ACTION=="add", SUBSYSTEM=="leds", RUN+="${chmod} g+w /sys/class/leds/%k/brightness" + ''; } diff --git a/users/common/options/home-manager/hyprland/default.nix b/users/common/options/home-manager/hyprland/default.nix index 4bd6480..71e6170 100644 --- a/users/common/options/home-manager/hyprland/default.nix +++ b/users/common/options/home-manager/hyprland/default.nix @@ -19,20 +19,18 @@ in }; config = { - wayland.windowManager.hyprland.settings.exec-once = let name = "init-hyprland"; in - "${pkgs.writeShellApplication { - inherit name; - text = '' - ${cfg.initExtraConfig} - ''; - }}/bin/${name}"; + wayland.windowManager.hyprland.settings.exec-once = lib.meta.getExe (pkgs.writeShellApplication { + name = "init-hyprland"; + text = '' + ${cfg.initExtraConfig} + ''; + }); - wayland.windowManager.hyprland.settings.exec = let name = "reload-hyprland"; in - "${pkgs.writeShellApplication { - inherit name; - text = '' - ${cfg.reloadExtraConfig} - ''; - }}/bin/${name}"; + wayland.windowManager.hyprland.settings.exec = lib.meta.getExe (pkgs.writeShellApplication { + name = "reload-hyprland"; + text = '' + ${cfg.reloadExtraConfig} + ''; + }); }; } diff --git a/users/configs/brightnessctl/default.nix b/users/configs/brightnessctl/default.nix index 0a41730..a9225b7 100644 --- a/users/configs/brightnessctl/default.nix +++ b/users/configs/brightnessctl/default.nix @@ -1,10 +1,14 @@ -{ user ? throw "user argument is required" }: { pkgs, ... }: +{ user ? throw "user argument is required" }: { lib, pkgs, ... }: { - home-manager.users."${user.name}" = { - wayland.windowManager.hyprland.settings.bindle = [ - ", XF86MonBrightnessUp, exec, ${pkgs.brightnessctl}/bin/brightnessctl -q s 5%+" - ", XF86MonBrightnessDown, exec, ${pkgs.brightnessctl}/bin/brightnessctl -q s 5%-" - ]; - }; + home-manager.users."${user.name}" = + let + brightnessctl = lib.meta.getExe pkgs.brightnessctl; + in + { + wayland.windowManager.hyprland.settings.bindle = [ + ", XF86MonBrightnessUp, exec, ${brightnessctl} -q s 5%+" + ", XF86MonBrightnessDown, exec, ${brightnessctl} -q s 5%-" + ]; + }; } diff --git a/users/configs/firefox/default.nix b/users/configs/firefox/default.nix index 09f11fa..79c4b4d 100644 --- a/users/configs/firefox/default.nix +++ b/users/configs/firefox/default.nix @@ -1,4 +1,4 @@ -{ user ? throw "user argument is required" }: { pkgs, ... }: +{ user ? throw "user argument is required" }: { lib, pkgs, ... }: { home-manager.users."${user.name}" = { @@ -89,7 +89,7 @@ }; wayland.windowManager.hyprland.settings.bind = [ - "$mod, b, exec, ${pkgs.firefox}/bin/firefox" + "$mod, b, exec, ${lib.meta.getExe pkgs.firefox}" ]; home.persistence = { diff --git a/users/configs/git/default.nix b/users/configs/git/default.nix index 8e38b7f..148e8fe 100644 --- a/users/configs/git/default.nix +++ b/users/configs/git/default.nix @@ -1,4 +1,4 @@ -{ user ? throw "user argument is required" }: { config, pkgs, ... }: +{ user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let hmConfig = config.home-manager.users."${user.name}"; @@ -22,12 +22,11 @@ in }; hooks = { - commit-msg = let name = "git-commit-msg-hook"; in - "${pkgs.writeShellApplication { - inherit name; + commit-msg = lib.meta.getExe (pkgs.writeShellApplication { + name = "git-commit-msg-hook"; runtimeInputs = with pkgs; [ git ]; text = builtins.readFile ./commit-msg.sh; - }}/bin/${name}"; + }); }; }; diff --git a/users/configs/gpg-agent/default.nix b/users/configs/gpg-agent/default.nix index 23de8aa..7fd3f16 100644 --- a/users/configs/gpg-agent/default.nix +++ b/users/configs/gpg-agent/default.nix @@ -20,9 +20,8 @@ in systemd.user = { services.gpg-agent-import = let - name = "import-gpg-keys"; - init = pkgs.writeShellApplication { - inherit name; + init = lib.meta.getExe (pkgs.writeShellApplication { + name = "import-gpg-keys"; runtimeInputs = with pkgs; [ coreutils-full gnugrep @@ -33,7 +32,7 @@ in HOME = user.home; }; text = builtins.readFile ./import-gpg-keys.sh; - }; + }); in { Unit = { @@ -44,7 +43,7 @@ in Service = { Type = "oneshot"; - ExecStart = "${init}/bin/${name}"; + ExecStart = init; }; Install.WantedBy = [ "default.target" ]; diff --git a/users/configs/gtk/default.nix b/users/configs/gtk/default.nix index 38e5e11..b6696ef 100644 --- a/users/configs/gtk/default.nix +++ b/users/configs/gtk/default.nix @@ -1,4 +1,4 @@ -{ user ? throw "user argument is required" }: { config, pkgs, ... }: +{ user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let hmConfig = config.home-manager.users."${user.name}"; @@ -29,22 +29,21 @@ in }; }; - theme.extraConfig = let name = "theme-gtk"; in - "${pkgs.writeShellApplication { - inherit name; - runtimeInputs = with pkgs; [ dconf ]; - text = '' - MODE=$(cat "${hmConfig.theme.configDir}/mode") + theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { + name = "theme-gtk"; + runtimeInputs = with pkgs; [ dconf ]; + text = '' + MODE=$(cat "${hmConfig.theme.configDir}/mode") - if [ "$MODE" = "light" ]; then - GTK_THEME="adw-gtk3" - else - GTK_THEME="adw-gtk3-dark" - fi + if [ "$MODE" = "light" ]; then + GTK_THEME="adw-gtk3" + else + GTK_THEME="adw-gtk3-dark" + fi - dconf write /org/gnome/desktop/interface/gtk-theme "'$GTK_THEME'" - dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$MODE'" - ''; - }}/bin/${name} &"; + dconf write /org/gnome/desktop/interface/gtk-theme "'$GTK_THEME'" + dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$MODE'" + ''; + })} &"; }; } diff --git a/users/configs/hyprland/default.nix b/users/configs/hyprland/default.nix index 6c95d81..653086d 100644 --- a/users/configs/hyprland/default.nix +++ b/users/configs/hyprland/default.nix @@ -8,7 +8,7 @@ enable = true; settings = { "$mod" = "SUPER"; - "$term" = "${pkgs.kitty}/bin/kitty"; + "$term" = lib.meta.getExe pkgs.kitty; bind = [ "$mod, Return, exec, $term" @@ -103,14 +103,13 @@ fi ''; - theme.extraConfig = let name = "reload-hyprland"; in - "${pkgs.writeShellApplication { - inherit name; + theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { + name = "reload-hyprland"; runtimeInputs = with pkgs; [ hyprland ]; text = '' hyprctl reload ''; - }}/bin/${name} &"; + })} &"; home.sessionVariables.NIXOS_OZONE_WL = "1"; }; diff --git a/users/configs/kitty/default.nix b/users/configs/kitty/default.nix index 725674e..3370fa5 100644 --- a/users/configs/kitty/default.nix +++ b/users/configs/kitty/default.nix @@ -1,4 +1,4 @@ -{ user ? throw "user argument is required" }: { config, pkgs, ... }: +{ user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let hmConfig = config.home-manager.users."${user.name}"; @@ -20,14 +20,13 @@ in }; }; - theme.extraConfig = let name = "reload-kitty"; in - "${pkgs.writeShellApplication { - inherit name; - runtimeInputs = with pkgs; [ procps ]; - text = '' - pkill kitty -SIGUSR1 - ''; - }}/bin/${name} &"; + theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { + name = "reload-kitty"; + runtimeInputs = with pkgs; [ procps ]; + text = '' + pkill kitty -SIGUSR1 + ''; + })} &"; home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ]; }; diff --git a/users/configs/matugen/default.nix b/users/configs/matugen/default.nix index 12369af..d4b3270 100644 --- a/users/configs/matugen/default.nix +++ b/users/configs/matugen/default.nix @@ -56,16 +56,15 @@ in }; }; - theme.extraConfig = let name = "theme-matugen"; in - lib.mkBefore "${pkgs.writeShellApplication { - inherit name; - runtimeInputs = with pkgs; [ matugen ]; - text = '' - matugen image "${hmConfig.theme.configDir}/wallpaper" \ - --type scheme-${hmConfig.theme.flavour} \ - --mode "$(cat "${hmConfig.theme.configDir}/mode")" \ - --contrast ${builtins.toString hmConfig.theme.contrast} - ''; - }}/bin/${name}"; + theme.extraConfig = lib.mkBefore (lib.meta.getExe (pkgs.writeShellApplication { + name = "theme-matugen"; + runtimeInputs = with pkgs; [ matugen ]; + text = '' + matugen image "${hmConfig.theme.configDir}/wallpaper" \ + --type scheme-${hmConfig.theme.flavour} \ + --mode "$(cat "${hmConfig.theme.configDir}/mode")" \ + --contrast ${builtins.toString hmConfig.theme.contrast} + ''; + })); }; } diff --git a/users/configs/pipewire/default.nix b/users/configs/pipewire/default.nix index ba4d9f5..1711e61 100644 --- a/users/configs/pipewire/default.nix +++ b/users/configs/pipewire/default.nix @@ -2,18 +2,22 @@ { home-manager.users."${user.name}" = { - wayland.windowManager.hyprland.settings = { - bindle = [ - ", XF86AudioRaiseVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ -l 2.0 2%+" - ", XF86AudioLowerVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ -l 2.0 2%-" - "CTRL, XF86AudioRaiseVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SOURCE@ -l 1.0 2%+" - "CTRL, XF86AudioLowerVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SOURCE@ -l 1.0 2%-" - ]; + wayland.windowManager.hyprland.settings = + let + wpctl = "${pkgs.wireplumber}/bin/wpctl"; + in + { + bindle = [ + ", XF86AudioRaiseVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ -l 2.0 2%+" + ", XF86AudioLowerVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ -l 2.0 2%-" + "CTRL, XF86AudioRaiseVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SOURCE@ -l 1.0 2%+" + "CTRL, XF86AudioLowerVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SOURCE@ -l 1.0 2%-" + ]; - bindl = [ - ", XF86AudioMute, exec, ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" - ", XF86AudioMicMute, exec, ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle" - ]; - }; + bindl = [ + ", XF86AudioMute, exec, ${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle" + ", XF86AudioMicMute, exec, ${wpctl} set-mute @DEFAULT_AUDIO_SOURCE@ toggle" + ]; + }; }; } diff --git a/users/configs/playerctl/default.nix b/users/configs/playerctl/default.nix index a1204a6..9dba29e 100644 --- a/users/configs/playerctl/default.nix +++ b/users/configs/playerctl/default.nix @@ -1,17 +1,21 @@ -{ user ? throw "user argument is required" }: { pkgs, ... }: +{ user ? throw "user argument is required" }: { lib, pkgs, ... }: { home-manager.users."${user.name}" = { home.packages = with pkgs; [ playerctl ]; services.playerctld.enable = true; - wayland.windowManager.hyprland.settings.bindle = [ - ", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause" - ", XF86AudioStop, exec, ${pkgs.playerctl}/bin/playerctl stop" - ", XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl next" - ", XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl previous" - "CTRL, XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl position 10+" - "CTRL, XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl position 10-" - ]; + wayland.windowManager.hyprland.settings.bindle = + let + playerctl = lib.meta.getExe pkgs.playerctl; + in + [ + ", XF86AudioPlay, exec, ${playerctl} play-pause" + ", XF86AudioStop, exec, ${playerctl} stop" + ", XF86AudioNext, exec, ${playerctl} next" + ", XF86AudioPrev, exec, ${playerctl} previous" + "CTRL, XF86AudioNext, exec, ${playerctl} position 10+" + "CTRL, XF86AudioPrev, exec, ${playerctl} position 10-" + ]; }; } diff --git a/users/configs/qalculate/default.nix b/users/configs/qalculate/default.nix index 6cd4afc..9769e54 100644 --- a/users/configs/qalculate/default.nix +++ b/users/configs/qalculate/default.nix @@ -1,11 +1,11 @@ -{ user ? throw "user argument is required" }: { config, pkgs, ... }: +{ user ? throw "user argument is required" }: { lib, config, pkgs, ... }: { home-manager.users."${user.name}" = { home.packages = with pkgs; [ qalculate-gtk ]; wayland.windowManager.hyprland.settings.bind = [ - ", XF86Calculator, exec, ${pkgs.qalculate-gtk}/bin/qalculate-gtk" + ", XF86Calculator, exec, ${lib.meta.getExe pkgs.qalculate-gtk}" ]; }; } diff --git a/users/configs/rofi/default.nix b/users/configs/rofi/default.nix index 467288d..2ee8111 100644 --- a/users/configs/rofi/default.nix +++ b/users/configs/rofi/default.nix @@ -1,4 +1,4 @@ -{ user ? throw "user argument is required" }: { config, pkgs, ... }: +{ user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let hmConfig = config.home-manager.users."${user.name}"; @@ -11,7 +11,7 @@ in }; wayland.windowManager.hyprland.settings.bind = [ - "$mod, r, exec, ${pkgs.rofi-wayland}/bin/rofi -cache-dir ${hmConfig.xdg.cacheHome}/rofi -show drun" + "$mod, r, exec, ${lib.meta.getExe pkgs.rofi-wayland} -cache-dir ${hmConfig.xdg.cacheHome}/rofi -show drun" ]; }; } diff --git a/users/configs/swww/default.nix b/users/configs/swww/default.nix index 2f5a991..d4fde05 100644 --- a/users/configs/swww/default.nix +++ b/users/configs/swww/default.nix @@ -10,30 +10,28 @@ in persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ]; }; - wayland.windowManager.hyprland.initExtraConfig = let name = "init-swww"; in - "${pkgs.writeShellApplication { - inherit name; - runtimeInputs = with pkgs; [ swww ]; - text = '' - swww-daemon &> /tmp/swww.log - ''; - }}/bin/${name} &"; + wayland.windowManager.hyprland.initExtraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { + name = "init-swww"; + runtimeInputs = with pkgs; [ swww ]; + text = '' + swww-daemon &> /tmp/swww.log + ''; + })} &"; - theme.extraConfig = let name = "theme-swww"; in - lib.mkAfter "${pkgs.writeShellApplication { - inherit name; - runtimeInputs = with pkgs; [ - coreutils-full - procps - swww - ]; - text = '' - while ! swww query &> /dev/null; do - sleep 0.1 - done + theme.extraConfig = lib.mkAfter "${lib.meta.getExe (pkgs.writeShellApplication { + name = "theme-swww"; + runtimeInputs = with pkgs; [ + coreutils-full + procps + swww + ]; + text = '' + while ! swww query &> /dev/null; do + sleep 0.1 + done - swww img "${hmConfig.theme.configDir}/wallpaper" - ''; - }}/bin/${name} &"; + swww img "${hmConfig.theme.configDir}/wallpaper" + ''; + })} &"; }; } diff --git a/users/configs/theme/default.nix b/users/configs/theme/default.nix index 9b65313..e736d8a 100644 --- a/users/configs/theme/default.nix +++ b/users/configs/theme/default.nix @@ -2,6 +2,7 @@ let hmConfig = config.home-manager.users."${user.name}"; + themeBin = lib.meta.getExe hmConfig.theme.pkg; in { home-manager.users."${user.name}" = { @@ -9,18 +10,18 @@ in wayland.windowManager.hyprland = { initExtraConfig = '' - ${hmConfig.theme.pkg}/bin/theme & + ${themeBin} & ''; settings.bind = [ - "CTRL_ALT, r, exec, ${hmConfig.theme.pkg}/bin/theme" - "CTRL_ALT, t, exec, ${hmConfig.theme.pkg}/bin/theme toggle" + "CTRL_ALT, r, exec, ${themeBin}" + "CTRL_ALT, t, exec, ${themeBin} toggle" ]; }; home = { activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] '' - run ${hmConfig.theme.pkg}/bin/theme + run ${themeBin} ''; persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeConfigHome}/theme" ]; diff --git a/users/configs/vscode/default.nix b/users/configs/vscode/default.nix index 2468fbc..6905981 100644 --- a/users/configs/vscode/default.nix +++ b/users/configs/vscode/default.nix @@ -41,7 +41,7 @@ "git.enableSmartCommit" = true; "git.ignoreRebaseWarning" = true; "git.openRepositoryInParentFolders" = "always"; - "git.path" = "${pkgs.git}/bin/git"; + "git.path" = lib.meta.getExe pkgs.git; "mergeEditor.diffAlgorithm" = "advanced"; "open-in-browser.default" = "firefox"; "security.workspace.trust.enabled" = false;