flocon/modules/programs/wlogout.nix
Anthony Rodriguez 6ab835555c
treewide: remove home-manager (switch to hjem)
As my NixOS configuration kept growing, I noticed that I don't need
home-manager as much as I did before. A lot of what I need is just a way
to map nix attrsets to the program's respective configuration format,
which is something that I can now do myself, as my nix knowledge got
more extensive. After all of this, I decided to completely get rid of
home-manager, and switch to a simpler solution called hjem, which just
lets me write files to my home directory that are automatically
symlinked using `systemd-tmpfiles`.

This allows me to simplify my configuration, remove the separation
between NixOS and home-manager modules, and cut my eval times by quite a
lot (which allows for faster `nixos-rebuild switch`!).
2025-01-27 23:57:47 +01:00

75 lines
1.7 KiB
Nix

{
lib,
pkgs,
config,
...
}: let
inherit (config.local.systemVars) username;
mkLayout = items: let
formatItem = item: ''
{
"label" : "${item.label}",
"action" : "${item.action}",
"text" : "${item.text}",
"keybind" : "${item.keybind}"
}'';
in
builtins.concatStringsSep "\n" (map formatItem items);
in {
config = lib.mkIf config.local.modules.hyprland.enable {
hjem.users.${username} = {
packages = [pkgs.wlogout];
files = {
".config/wlogout/layout".text = let
loginctl = lib.getExe' pkgs.systemd "loginctl";
systemctl = lib.getExe' pkgs.systemd "systemctl";
in
mkLayout [
{
action = "${loginctl} lock-session";
keybind = "l";
label = "lock";
text = "Lock";
}
{
action = "${systemctl} hibernate";
keybind = "h";
label = "hibernate";
text = "Hibernate";
}
{
action = "${loginctl} terminate-user ${username}";
keybind = "q";
label = "logout";
text = "Logout";
}
{
action = "${systemctl} poweroff";
keybind = "p";
label = "shutdown";
text = "Shutdown";
}
{
action = "${systemctl} suspend";
keybind = "s";
label = "suspend";
text = "Suspend";
}
{
action = "${systemctl} reboot";
keybind = "r";
label = "reboot";
text = "Reboot";
}
];
};
};
};
}