Use lib.meta.getExe

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-25 20:16:42 +03:00
parent eaa63dd272
commit d9a3936d51
17 changed files with 141 additions and 133 deletions

View File

@@ -3,10 +3,15 @@
{ {
environment.systemPackages = with pkgs; [ brightnessctl ]; environment.systemPackages = with pkgs; [ brightnessctl ];
services.udev.extraRules = '' services.udev.extraRules =
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils-full}/bin/chgrp video /sys/class/backlight/%k/brightness" let
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils-full}/bin/chmod g+w /sys/class/backlight/%k/brightness" chgrp = "${pkgs.coreutils-full}/bin/chgrp";
ACTION=="add", SUBSYSTEM=="leds", RUN+="${pkgs.coreutils-full}/bin/chgrp input /sys/class/leds/%k/brightness" chmod = "${pkgs.coreutils-full}/bin/chmod";
ACTION=="add", SUBSYSTEM=="leds", RUN+="${pkgs.coreutils-full}/bin/chmod g+w /sys/class/leds/%k/brightness" 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"
''; '';
} }

View File

@@ -19,20 +19,18 @@ in
}; };
config = { config = {
wayland.windowManager.hyprland.settings.exec-once = let name = "init-hyprland"; in wayland.windowManager.hyprland.settings.exec-once = lib.meta.getExe (pkgs.writeShellApplication {
"${pkgs.writeShellApplication { name = "init-hyprland";
inherit name;
text = '' text = ''
${cfg.initExtraConfig} ${cfg.initExtraConfig}
''; '';
}}/bin/${name}"; });
wayland.windowManager.hyprland.settings.exec = let name = "reload-hyprland"; in wayland.windowManager.hyprland.settings.exec = lib.meta.getExe (pkgs.writeShellApplication {
"${pkgs.writeShellApplication { name = "reload-hyprland";
inherit name;
text = '' text = ''
${cfg.reloadExtraConfig} ${cfg.reloadExtraConfig}
''; '';
}}/bin/${name}"; });
}; };
} }

View File

@@ -1,10 +1,14 @@
{ user ? throw "user argument is required" }: { pkgs, ... }: { user ? throw "user argument is required" }: { lib, pkgs, ... }:
{ {
home-manager.users."${user.name}" = { home-manager.users."${user.name}" =
let
brightnessctl = lib.meta.getExe pkgs.brightnessctl;
in
{
wayland.windowManager.hyprland.settings.bindle = [ wayland.windowManager.hyprland.settings.bindle = [
", XF86MonBrightnessUp, exec, ${pkgs.brightnessctl}/bin/brightnessctl -q s 5%+" ", XF86MonBrightnessUp, exec, ${brightnessctl} -q s 5%+"
", XF86MonBrightnessDown, exec, ${pkgs.brightnessctl}/bin/brightnessctl -q s 5%-" ", XF86MonBrightnessDown, exec, ${brightnessctl} -q s 5%-"
]; ];
}; };
} }

View File

@@ -1,4 +1,4 @@
{ user ? throw "user argument is required" }: { pkgs, ... }: { user ? throw "user argument is required" }: { lib, pkgs, ... }:
{ {
home-manager.users."${user.name}" = { home-manager.users."${user.name}" = {
@@ -89,7 +89,7 @@
}; };
wayland.windowManager.hyprland.settings.bind = [ wayland.windowManager.hyprland.settings.bind = [
"$mod, b, exec, ${pkgs.firefox}/bin/firefox" "$mod, b, exec, ${lib.meta.getExe pkgs.firefox}"
]; ];
home.persistence = { home.persistence = {

View File

@@ -1,4 +1,4 @@
{ user ? throw "user argument is required" }: { config, pkgs, ... }: { user ? throw "user argument is required" }: { config, lib, pkgs, ... }:
let let
hmConfig = config.home-manager.users."${user.name}"; hmConfig = config.home-manager.users."${user.name}";
@@ -22,12 +22,11 @@ in
}; };
hooks = { hooks = {
commit-msg = let name = "git-commit-msg-hook"; in commit-msg = lib.meta.getExe (pkgs.writeShellApplication {
"${pkgs.writeShellApplication { name = "git-commit-msg-hook";
inherit name;
runtimeInputs = with pkgs; [ git ]; runtimeInputs = with pkgs; [ git ];
text = builtins.readFile ./commit-msg.sh; text = builtins.readFile ./commit-msg.sh;
}}/bin/${name}"; });
}; };
}; };

View File

@@ -20,9 +20,8 @@ in
systemd.user = { systemd.user = {
services.gpg-agent-import = services.gpg-agent-import =
let let
init = lib.meta.getExe (pkgs.writeShellApplication {
name = "import-gpg-keys"; name = "import-gpg-keys";
init = pkgs.writeShellApplication {
inherit name;
runtimeInputs = with pkgs; [ runtimeInputs = with pkgs; [
coreutils-full coreutils-full
gnugrep gnugrep
@@ -33,7 +32,7 @@ in
HOME = user.home; HOME = user.home;
}; };
text = builtins.readFile ./import-gpg-keys.sh; text = builtins.readFile ./import-gpg-keys.sh;
}; });
in in
{ {
Unit = { Unit = {
@@ -44,7 +43,7 @@ in
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
ExecStart = "${init}/bin/${name}"; ExecStart = init;
}; };
Install.WantedBy = [ "default.target" ]; Install.WantedBy = [ "default.target" ];

View File

@@ -1,4 +1,4 @@
{ user ? throw "user argument is required" }: { config, pkgs, ... }: { user ? throw "user argument is required" }: { config, lib, pkgs, ... }:
let let
hmConfig = config.home-manager.users."${user.name}"; hmConfig = config.home-manager.users."${user.name}";
@@ -29,9 +29,8 @@ in
}; };
}; };
theme.extraConfig = let name = "theme-gtk"; in theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication {
"${pkgs.writeShellApplication { name = "theme-gtk";
inherit name;
runtimeInputs = with pkgs; [ dconf ]; runtimeInputs = with pkgs; [ dconf ];
text = '' text = ''
MODE=$(cat "${hmConfig.theme.configDir}/mode") MODE=$(cat "${hmConfig.theme.configDir}/mode")
@@ -45,6 +44,6 @@ in
dconf write /org/gnome/desktop/interface/gtk-theme "'$GTK_THEME'" dconf write /org/gnome/desktop/interface/gtk-theme "'$GTK_THEME'"
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$MODE'" dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$MODE'"
''; '';
}}/bin/${name} &"; })} &";
}; };
} }

View File

@@ -8,7 +8,7 @@
enable = true; enable = true;
settings = { settings = {
"$mod" = "SUPER"; "$mod" = "SUPER";
"$term" = "${pkgs.kitty}/bin/kitty"; "$term" = lib.meta.getExe pkgs.kitty;
bind = [ bind = [
"$mod, Return, exec, $term" "$mod, Return, exec, $term"
@@ -103,14 +103,13 @@
fi fi
''; '';
theme.extraConfig = let name = "reload-hyprland"; in theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication {
"${pkgs.writeShellApplication { name = "reload-hyprland";
inherit name;
runtimeInputs = with pkgs; [ hyprland ]; runtimeInputs = with pkgs; [ hyprland ];
text = '' text = ''
hyprctl reload hyprctl reload
''; '';
}}/bin/${name} &"; })} &";
home.sessionVariables.NIXOS_OZONE_WL = "1"; home.sessionVariables.NIXOS_OZONE_WL = "1";
}; };

View File

@@ -1,4 +1,4 @@
{ user ? throw "user argument is required" }: { config, pkgs, ... }: { user ? throw "user argument is required" }: { config, lib, pkgs, ... }:
let let
hmConfig = config.home-manager.users."${user.name}"; hmConfig = config.home-manager.users."${user.name}";
@@ -20,14 +20,13 @@ in
}; };
}; };
theme.extraConfig = let name = "reload-kitty"; in theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication {
"${pkgs.writeShellApplication { name = "reload-kitty";
inherit name;
runtimeInputs = with pkgs; [ procps ]; runtimeInputs = with pkgs; [ procps ];
text = '' text = ''
pkill kitty -SIGUSR1 pkill kitty -SIGUSR1
''; '';
}}/bin/${name} &"; })} &";
home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ]; home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ];
}; };

View File

@@ -56,9 +56,8 @@ in
}; };
}; };
theme.extraConfig = let name = "theme-matugen"; in theme.extraConfig = lib.mkBefore (lib.meta.getExe (pkgs.writeShellApplication {
lib.mkBefore "${pkgs.writeShellApplication { name = "theme-matugen";
inherit name;
runtimeInputs = with pkgs; [ matugen ]; runtimeInputs = with pkgs; [ matugen ];
text = '' text = ''
matugen image "${hmConfig.theme.configDir}/wallpaper" \ matugen image "${hmConfig.theme.configDir}/wallpaper" \
@@ -66,6 +65,6 @@ in
--mode "$(cat "${hmConfig.theme.configDir}/mode")" \ --mode "$(cat "${hmConfig.theme.configDir}/mode")" \
--contrast ${builtins.toString hmConfig.theme.contrast} --contrast ${builtins.toString hmConfig.theme.contrast}
''; '';
}}/bin/${name}"; }));
}; };
} }

View File

@@ -2,17 +2,21 @@
{ {
home-manager.users."${user.name}" = { home-manager.users."${user.name}" = {
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings =
let
wpctl = "${pkgs.wireplumber}/bin/wpctl";
in
{
bindle = [ bindle = [
", XF86AudioRaiseVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ -l 2.0 2%+" ", XF86AudioRaiseVolume, exec, ${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%-" ", XF86AudioLowerVolume, exec, ${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, XF86AudioRaiseVolume, exec, ${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%-" "CTRL, XF86AudioLowerVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SOURCE@ -l 1.0 2%-"
]; ];
bindl = [ bindl = [
", XF86AudioMute, exec, ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" ", XF86AudioMute, exec, ${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle"
", XF86AudioMicMute, exec, ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle" ", XF86AudioMicMute, exec, ${wpctl} set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
]; ];
}; };
}; };

View File

@@ -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-manager.users."${user.name}" = {
home.packages = with pkgs; [ playerctl ]; home.packages = with pkgs; [ playerctl ];
services.playerctld.enable = true; services.playerctld.enable = true;
wayland.windowManager.hyprland.settings.bindle = [ wayland.windowManager.hyprland.settings.bindle =
", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause" let
", XF86AudioStop, exec, ${pkgs.playerctl}/bin/playerctl stop" playerctl = lib.meta.getExe pkgs.playerctl;
", XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl next" in
", XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl previous" [
"CTRL, XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl position 10+" ", XF86AudioPlay, exec, ${playerctl} play-pause"
"CTRL, XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl position 10-" ", XF86AudioStop, exec, ${playerctl} stop"
", XF86AudioNext, exec, ${playerctl} next"
", XF86AudioPrev, exec, ${playerctl} previous"
"CTRL, XF86AudioNext, exec, ${playerctl} position 10+"
"CTRL, XF86AudioPrev, exec, ${playerctl} position 10-"
]; ];
}; };
} }

View File

@@ -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-manager.users."${user.name}" = {
home.packages = with pkgs; [ qalculate-gtk ]; home.packages = with pkgs; [ qalculate-gtk ];
wayland.windowManager.hyprland.settings.bind = [ wayland.windowManager.hyprland.settings.bind = [
", XF86Calculator, exec, ${pkgs.qalculate-gtk}/bin/qalculate-gtk" ", XF86Calculator, exec, ${lib.meta.getExe pkgs.qalculate-gtk}"
]; ];
}; };
} }

View File

@@ -1,4 +1,4 @@
{ user ? throw "user argument is required" }: { config, pkgs, ... }: { user ? throw "user argument is required" }: { config, lib, pkgs, ... }:
let let
hmConfig = config.home-manager.users."${user.name}"; hmConfig = config.home-manager.users."${user.name}";
@@ -11,7 +11,7 @@ in
}; };
wayland.windowManager.hyprland.settings.bind = [ 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"
]; ];
}; };
} }

View File

@@ -10,18 +10,16 @@ in
persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ]; persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ];
}; };
wayland.windowManager.hyprland.initExtraConfig = let name = "init-swww"; in wayland.windowManager.hyprland.initExtraConfig = "${lib.meta.getExe (pkgs.writeShellApplication {
"${pkgs.writeShellApplication { name = "init-swww";
inherit name;
runtimeInputs = with pkgs; [ swww ]; runtimeInputs = with pkgs; [ swww ];
text = '' text = ''
swww-daemon &> /tmp/swww.log swww-daemon &> /tmp/swww.log
''; '';
}}/bin/${name} &"; })} &";
theme.extraConfig = let name = "theme-swww"; in theme.extraConfig = lib.mkAfter "${lib.meta.getExe (pkgs.writeShellApplication {
lib.mkAfter "${pkgs.writeShellApplication { name = "theme-swww";
inherit name;
runtimeInputs = with pkgs; [ runtimeInputs = with pkgs; [
coreutils-full coreutils-full
procps procps
@@ -34,6 +32,6 @@ in
swww img "${hmConfig.theme.configDir}/wallpaper" swww img "${hmConfig.theme.configDir}/wallpaper"
''; '';
}}/bin/${name} &"; })} &";
}; };
} }

View File

@@ -2,6 +2,7 @@
let let
hmConfig = config.home-manager.users."${user.name}"; hmConfig = config.home-manager.users."${user.name}";
themeBin = lib.meta.getExe hmConfig.theme.pkg;
in in
{ {
home-manager.users."${user.name}" = { home-manager.users."${user.name}" = {
@@ -9,18 +10,18 @@ in
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
initExtraConfig = '' initExtraConfig = ''
${hmConfig.theme.pkg}/bin/theme & ${themeBin} &
''; '';
settings.bind = [ settings.bind = [
"CTRL_ALT, r, exec, ${hmConfig.theme.pkg}/bin/theme" "CTRL_ALT, r, exec, ${themeBin}"
"CTRL_ALT, t, exec, ${hmConfig.theme.pkg}/bin/theme toggle" "CTRL_ALT, t, exec, ${themeBin} toggle"
]; ];
}; };
home = { home = {
activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] '' 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" ]; persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeConfigHome}/theme" ];

View File

@@ -41,7 +41,7 @@
"git.enableSmartCommit" = true; "git.enableSmartCommit" = true;
"git.ignoreRebaseWarning" = true; "git.ignoreRebaseWarning" = true;
"git.openRepositoryInParentFolders" = "always"; "git.openRepositoryInParentFolders" = "always";
"git.path" = "${pkgs.git}/bin/git"; "git.path" = lib.meta.getExe pkgs.git;
"mergeEditor.diffAlgorithm" = "advanced"; "mergeEditor.diffAlgorithm" = "advanced";
"open-in-browser.default" = "firefox"; "open-in-browser.default" = "firefox";
"security.workspace.trust.enabled" = false; "security.workspace.trust.enabled" = false;