From 9d5b8eff9c314d5d723210913a54cc183c7bb72c Mon Sep 17 00:00:00 2001 From: Lilly Date: Mon, 5 Jan 2026 06:05:30 +0100 Subject: [PATCH] Add Hyprland Toggle --- home/default.nix | 2 +- home/hyprland.nix | 15 +++++++++ home/hyprland/default.nix | 46 +++++++++++----------------- home/hyprland/rules/default.nix | 20 ++++++++++++ modules/desktop/glib-schemas-fix.nix | 10 +++--- modules/desktop/hyprland.nix | 4 +-- 6 files changed, 62 insertions(+), 35 deletions(-) create mode 100644 home/hyprland.nix create mode 100644 home/hyprland/rules/default.nix diff --git a/home/default.nix b/home/default.nix index 18ed1e6..cefb09e 100644 --- a/home/default.nix +++ b/home/default.nix @@ -15,6 +15,6 @@ let b.map (f: ./${f}); in { - imports = module_files; + imports = module_files ++ [./hyprland]; nixpkgs.config.allowUnfree = true; } \ No newline at end of file diff --git a/home/hyprland.nix b/home/hyprland.nix new file mode 100644 index 0000000..005087b --- /dev/null +++ b/home/hyprland.nix @@ -0,0 +1,15 @@ +{ inputs, pkgs, lib, config, ... }: +let + cfg = config.my.desktop.hyprland; +in +{ + programs.kitty.enable = config.my.desktop.enable; # required for the default Hyprland config + wayland.windowManager.hyprland = lib.mkIf cfg.enable { + enable = true; + # set the flake package + package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; + # make sure to also set the portal package, so that they are in sync + portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland; + systemd.enable = true; + }; +} \ No newline at end of file diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index 16a7d57..09a4da8 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -1,29 +1,19 @@ -{ inputs, pkgs, ... }: +{ lib, ... }: +let + b = builtins; + + module_files = + b.readDir ./. |> + lib.filterAttrs (name: type: + ( (lib.strings.hasSuffix ".nix" name + && name != "default.nix" + && type == "regular" ) + || ( type == "directory" + && b.pathExists ./${name}/default.nix)) + ) |> + b.attrNames |> + b.map (f: ./${f}); +in { - programs.kitty.enable = true; # required for the default Hyprland config - wayland.windowManager.hyprland = { - enable = true; - # set the flake package - package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; - # make sure to also set the portal package, so that they are in sync - portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland; - systemd.enable = true; - }; - - imports = [ - ./animations.nix - ./execs.nix - ./general.nix - ./hypridle.nix - ./input.nix - ./keybinds.nix - ./misc.nix - ./monitors.nix - ./theme.nix - ./rules/windows.nix - ./rules/workspaces.nix - ]; - -# xdg.configFile."hypr".source = ./hypr; -# home.sessionVariables.NIXOS_OZONE_WL = "1"; -} + imports = module_files; +} \ No newline at end of file diff --git a/home/hyprland/rules/default.nix b/home/hyprland/rules/default.nix new file mode 100644 index 0000000..18ed1e6 --- /dev/null +++ b/home/hyprland/rules/default.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + b = builtins; + + module_files = + b.readDir ./. |> + lib.filterAttrs (name: type: + ( (lib.strings.hasSuffix ".nix" name + && name != "default.nix" + && type == "regular" ) + || ( type == "directory" + && b.pathExists ./${name}/default.nix)) + ) |> + b.attrNames |> + b.map (f: ./${f}); +in +{ + imports = module_files; + nixpkgs.config.allowUnfree = true; +} \ No newline at end of file diff --git a/modules/desktop/glib-schemas-fix.nix b/modules/desktop/glib-schemas-fix.nix index e96c3a2..fd432e4 100644 --- a/modules/desktop/glib-schemas-fix.nix +++ b/modules/desktop/glib-schemas-fix.nix @@ -1,12 +1,14 @@ # Glib Schemas Fix # https://github.com/thomX75/nixos-modules -{ pkgs, ... }: +{ config, lib, pkgs, ... }: { - environment.systemPackages = with pkgs; [ gsettings-desktop-schemas ]; + config = lib.mkIf config.my.desktop.enable { + environment.systemPackages = with pkgs; [ gsettings-desktop-schemas ]; - environment.variables = { - GSETTINGS_SCHEMA_DIR="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}/glib-2.0/schemas"; + environment.variables = { + GSETTINGS_SCHEMA_DIR="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}/glib-2.0/schemas"; + }; }; } \ No newline at end of file diff --git a/modules/desktop/hyprland.nix b/modules/desktop/hyprland.nix index d6e281d..f556f85 100644 --- a/modules/desktop/hyprland.nix +++ b/modules/desktop/hyprland.nix @@ -1,6 +1,6 @@ -{ inputs, pkgs, ...}: +{ inputs, pkgs, config, lib, ...}: { - programs.hyprland = { + programs.hyprland = lib.mkIf config.my.desktop.hyprland.enable { enable = true; # set the flake package package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;