From ba3d1e25bc86d2d1b30aac502728fa3696ee0b02 Mon Sep 17 00:00:00 2001 From: Sergei Bulavintsev Date: Wed, 21 Feb 2024 14:50:42 +0300 Subject: [PATCH] feat(nix): move hyprland to hm --- nix/homes/x86_64-linux/sab@nz/default.nix | 2 +- .../home/desktop/addons/hypridle/default.nix | 41 +++++++++++++++++ nix/modules/home/desktop/hyprland/default.nix | 26 +++++++++++ .../desktop/hyprland/hyprland.conf | 0 .../hyprland-utils}/default.nix | 44 +++---------------- nix/modules/nixos/home/default.nix | 6 --- nix/modules/nixos/suites/desktop/default.nix | 8 +++- 7 files changed, 81 insertions(+), 46 deletions(-) create mode 100644 nix/modules/home/desktop/addons/hypridle/default.nix create mode 100644 nix/modules/home/desktop/hyprland/default.nix rename nix/modules/{nixos => home}/desktop/hyprland/hyprland.conf (100%) rename nix/modules/nixos/desktop/{hyprland => addons/hyprland-utils}/default.nix (61%) diff --git a/nix/homes/x86_64-linux/sab@nz/default.nix b/nix/homes/x86_64-linux/sab@nz/default.nix index ba814a1..4c1683a 100644 --- a/nix/homes/x86_64-linux/sab@nz/default.nix +++ b/nix/homes/x86_64-linux/sab@nz/default.nix @@ -14,8 +14,8 @@ with lib.custom; { }; desktop = { + hyprland = enabled; addons = { - # gtk = enabled; hyprpaper = enabled; mako = enabled; rofi = enabled; diff --git a/nix/modules/home/desktop/addons/hypridle/default.nix b/nix/modules/home/desktop/addons/hypridle/default.nix new file mode 100644 index 0000000..3d19832 --- /dev/null +++ b/nix/modules/home/desktop/addons/hypridle/default.nix @@ -0,0 +1,41 @@ +{ + inputs, + options, + config, + lib, + pkgs, + ... +}: +with lib; +with lib.custom; let + cfg = config.custom.desktop.addons.hypridle; + inherit (inputs) hypridle; +in { + imports = [hypridle.homeManagerModules.default]; + + options.custom.desktop.addons.hypridle = with types; { + enable = mkBoolOpt false "Whether to enable the hypridle"; + }; + + config = mkIf cfg.enable { + services.hypridle = { + enable = true; + package = pkgs.hypridle; + + lockCmd = "${getExe config.programs.hypridle.package}"; + afterSleepCmd = "${getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch dpms on"; + + listeners = [ + { + timeout = 900; + onTimeout = "${getExe config.programs.hypridle.package}"; + } + { + timeout = 1200; + onTimeout = "${getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch dpms off"; + onResume = "${getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch dpms on"; + } + ]; + }; + }; +} diff --git a/nix/modules/home/desktop/hyprland/default.nix b/nix/modules/home/desktop/hyprland/default.nix new file mode 100644 index 0000000..00a3bc5 --- /dev/null +++ b/nix/modules/home/desktop/hyprland/default.nix @@ -0,0 +1,26 @@ +{ + options, + config, + lib, + pkgs, + ... +}: +with lib; +with lib.custom; let + cfg = config.custom.desktop.hyprland; +in { + options.custom.desktop.hyprland = with types; { + enable = mkBoolOpt false "Whether or not to install Hyprland and dependencies."; + }; + + config = mkIf cfg.enable { + wayland.windowManager.hyprland = { + enable = true; + extraConfig = + builtins.readFile ./hyprland.conf; + + systemd.enable = true; + xwayland.enable = true; + }; + }; +} diff --git a/nix/modules/nixos/desktop/hyprland/hyprland.conf b/nix/modules/home/desktop/hyprland/hyprland.conf similarity index 100% rename from nix/modules/nixos/desktop/hyprland/hyprland.conf rename to nix/modules/home/desktop/hyprland/hyprland.conf diff --git a/nix/modules/nixos/desktop/hyprland/default.nix b/nix/modules/nixos/desktop/addons/hyprland-utils/default.nix similarity index 61% rename from nix/modules/nixos/desktop/hyprland/default.nix rename to nix/modules/nixos/desktop/addons/hyprland-utils/default.nix index 77ea8d5..c513e89 100644 --- a/nix/modules/nixos/desktop/hyprland/default.nix +++ b/nix/modules/nixos/desktop/addons/hyprland-utils/default.nix @@ -7,33 +7,19 @@ }: with lib; with lib.custom; let - cfg = config.custom.desktop.hyprland; + cfg = config.custom.desktop.addons.hyprland-utils; in { - options.custom.desktop.hyprland = with types; { - enable = mkBoolOpt false "Whether or not to install Hyprland and dependencies."; + options.custom.desktop.addons.hyprland-utils = with types; { + enable = mkBoolOpt false "Whether or not to add support for hyprland."; }; config = mkIf cfg.enable { - custom.desktop.addons = { - keyring = enabled; - # nautilus = enabled; - # thunar = enabled; - gtk = enabled; - # hyprpaper = enabled; - # kitty = enabled; - # mako = enabled; - regreet = enabled; - # rofi = enabled; - # swayidle = enabled; - # swaylock = enabled; - # waybar = enabled; - # wezterm = enabled; - # wlogout = enabled; - xdg-portal = enabled; + # Required as deps + programs.hyprland = { + enable = true; + xwayland.enable = true; }; - # home.configFile."hypr/hyprland.conf".source = ./hyprland.conf; - environment.systemPackages = with pkgs; [ # hyprland # hyprland-protocols @@ -66,22 +52,6 @@ in { XDG_SESSION_DESKTOP = "Hyprland"; XDG_SCREENSHOTS_DIR = "~/Pictures/Screenshots"; }; - - # Required as deps - programs.hyprland = { - enable = true; - xwayland.enable = true; - }; - - home.wayland.windowManager.hyprland = { - enable = true; - extraConfig = - builtins.readFile ./hyprland.conf; - - systemd.enable = true; - xwayland.enable = true; - }; - services.xserver = { enable = true; displayManager = { diff --git a/nix/modules/nixos/home/default.nix b/nix/modules/nixos/home/default.nix index 565306e..850cf0d 100644 --- a/nix/modules/nixos/home/default.nix +++ b/nix/modules/nixos/home/default.nix @@ -19,8 +19,6 @@ with lib.custom; { mkOpt attrs {} "A set of files to be managed by home-manager's ."; programs = mkOpt attrs {} "Programs to be managed by home-manager."; - services = mkOpt attrs {} "Services to be managed by home-manager."; - wayland = mkOpt attrs {} "Wayland to be managed by home-manager."; extraOptions = mkOpt attrs {} "Options to pass directly to home-manager."; }; @@ -29,10 +27,6 @@ with lib.custom; { home.file = mkAliasDefinitions options.home.file; home.stateVersion = config.system.stateVersion; programs = mkAliasDefinitions options.home.programs; - services = mkAliasDefinitions options.home.services; - wayland = mkAliasDefinitions options.home.wayland; - xdg.configFile = mkAliasDefinitions options.home.configFile; - xdg.enable = true; }; home-manager = { diff --git a/nix/modules/nixos/suites/desktop/default.nix b/nix/modules/nixos/suites/desktop/default.nix index eb6aece..cdbff7f 100644 --- a/nix/modules/nixos/suites/desktop/default.nix +++ b/nix/modules/nixos/suites/desktop/default.nix @@ -16,8 +16,12 @@ in { config = mkIf cfg.enable { system.security.rbw.enable = true; custom = { - desktop = { - hyprland = enabled; + desktop.addons = { + keyring = enabled; + gtk = enabled; + regreet = enabled; + xdg-portal = enabled; + hyprland-utils = enabled; }; apps = { firefox = enabled;