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 ];
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"
'';
}

View File

@@ -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}
'';
});
};
}

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}" = {
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%-"
];
};
}

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}" = {
@@ -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 = {

View File

@@ -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}";
});
};
};

View File

@@ -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" ];

View File

@@ -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'"
'';
})} &";
};
}

View File

@@ -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";
};

View File

@@ -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" ];
};

View File

@@ -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}
'';
}));
};
}

View File

@@ -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"
];
};
};
}

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.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-"
];
};
}

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.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}"
];
};
}

View File

@@ -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"
];
};
}

View File

@@ -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"
'';
})} &";
};
}

View File

@@ -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" ];

View File

@@ -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;