2022-12-18 14:20:19 +01:00
For a list of available options, check the
2023-07-21 16:21:14 +02:00
[Home Manager options ](https://nix-community.github.io/home-manager/options.html#opt-wayland.windowManager.hyprland.enable ).
2022-12-18 14:20:19 +01:00
2023-09-04 17:46:31 +02:00
{{< hint title = Note > }}
- *(Required) NixOS Module*: enables critical components needed to run Hyprland properly
- *(Optional) Home-manager module*: lets you declaratively configure Hyprland
{{< / hint > }}
2023-07-17 18:14:43 +02:00
## Installation
{{< tabs " uniqueid " > }}
2023-07-21 16:21:14 +02:00
{{< tab " Home Manager " > }}
Home Manager has options for Hyprland without needing to import the Flake module.
```nix
{
wayland.windowManager.hyprland.enable = true;
}
```
{{< / tab > }}
2023-07-17 18:14:43 +02:00
{{< tab " Flakes " > }}
2023-07-21 16:21:14 +02:00
The following snippet of code tries to show how to bring the Hyprland flake from
the flake input and import it into the module system. Feel free to make any
adjustment for your setup.
2023-07-17 18:14:43 +02:00
Don't forget to replace `user@hostname` with your username and hostname!
2022-12-18 14:20:19 +01:00
```nix
# flake.nix
2023-02-14 14:30:40 +01:00
2022-12-18 14:20:19 +01:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland.url = "github:hyprwm/Hyprland";
};
outputs = {nixpkgs, home-manager, hyprland, ...}: {
homeConfigurations."user@hostname" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [
hyprland.homeManagerModules.default
{wayland.windowManager.hyprland.enable = true;}
# ...
];
};
};
2022-12-28 16:31:43 +01:00
}
2022-12-18 14:20:19 +01:00
```
2023-07-17 18:14:43 +02:00
{{< / tab > }}
2022-12-18 14:20:19 +01:00
2023-07-17 18:14:43 +02:00
{{< tab " No flakes ( with flake-compat ) " > }}
2023-07-21 16:21:14 +02:00
The following snippet of code tries to show how to bring the Hyprland flake from
the flake input and import it into the module system. Feel free to make any
adjustment for your setup.
2022-12-18 14:20:19 +01:00
```nix
# home config
2023-02-14 14:30:40 +01:00
{pkgs, ...}: let
2022-12-18 14:20:19 +01:00
flake-compat = builtins.fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz";
hyprland = (import flake-compat {
src = builtins.fetchTarball "https://github.com/hyprwm/Hyprland/archive/master.tar.gz";
}).defaultNix;
in {
imports = [
hyprland.homeManagerModules.default
];
2023-02-14 14:30:40 +01:00
wayland.windowManager.hyprland = {
enable = true;
extraConfig = ''
bind = SUPER, Return, exec, kitty
# ...
'';
};
2022-12-18 14:20:19 +01:00
}
```
2023-07-17 18:14:43 +02:00
{{< / tab > }}
{{< / tabs > }}
## Usage
2023-07-21 16:21:14 +02:00
Once the module is enabled, you can use it to declaratively configure Hyprland.
Here is an example config, made to work with either the upstream Home Manager
module, or the Flake-based Home Manager module.
2023-07-17 18:14:43 +02:00
```nix
# home.nix
{config, pkgs, ...}: {
2023-07-21 16:21:14 +02:00
# hyprland module from HM
wayland.windowManager.hyprland.settings = {
"$mod" = "SUPER";
bind =
[
"$mod, F, exec, firefox"
", Print, exec, grimblast copy area"
]
++ (
# workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
builtins.concatLists (builtins.genList (
x: let
ws = let
c = (x + 1) / 10;
in
builtins.toString (x + 1 - (c * 10));
in [
"$mod, ${ws}, workspace, ${toString (x + 1)}"
"$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
]
)
10)
);
};
# hyprland module from the flake
2023-07-17 18:14:43 +02:00
wayland.windowManager.hyprland.extraConfig = ''
$mod = SUPER
bind = $mod, F, exec, firefox
bind = , Print, exec, grimblast copy area
# workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
${builtins.concatStringsSep "\n" (builtins.genList (
x: let
ws = let
c = (x + 1) / 10;
in
builtins.toString (x + 1 - (c * 10));
in ''
bind = $mod, ${ws}, workspace, ${toString (x + 1)}
bind = $mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}
''
)
10)}
# ...
'';
}
```
## Plugins
Hyprland plugins can be added through an option:
```nix
wayland.windowManager.hyprland.plugins = [
inputs.hyprland-plugins.packages.${pkgs.system}.hyprbars
"/absolute/path/to/plugin.so"
];
```
For examples on how to build hyprland plugins using nix see the
[official plugins ](https://github.com/hyprwm/hyprland-plugins ).
2023-10-17 08:04:44 +02:00
## Fixing problems with themes
If your themes for mouse cursor, icons or windows don't load correctly, try setting them with `home.pointerCursor` and `gtk.theme` , which enable a bunch of compatibility options that should make the themes load in all situations.
Example configuration:
```
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.username = {
home = {
stateVersion = "23.05";
pointerCursor = {
gtk.enable = true;
# x11.enable = true;
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Amber";
size = 32;
};
};
gtk = {
enable = true;
theme = {
package = pkgs.flat-remix-gtk;
name = "Flat-Remix-GTK-Grey-Darkest";
};
iconTheme = {
package = pkgs.libsForQt5.breeze-icons;
name = "breeze-dark";
};
font = {
name = "Sans";
size = 11;
};
};
};
};
```