2024-02-20 21:16:07 +01:00
|
|
|
---
|
|
|
|
title: Hyprland on Home Manager
|
|
|
|
---
|
|
|
|
|
2022-12-18 14:20:19 +01:00
|
|
|
For a list of available options, check the
|
2024-01-04 11:50:19 +01:00
|
|
|
[Home Manager options](https://nix-community.github.io/home-manager/options.xhtml#opt-wayland.windowManager.hyprland.enable).
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< callout >}}
|
2023-07-17 18:14:43 +02:00
|
|
|
|
2024-06-28 22:53:47 +02:00
|
|
|
- _**(Required)** NixOS Module_: enables critical components needed to run
|
|
|
|
Hyprland properly.
|
|
|
|
- _Without this, you may have issues with XDG Portals, or missing session
|
|
|
|
files in your Display Manager._
|
|
|
|
- _(Optional) Home Manager module_: lets you configure Hyprland declaratively
|
|
|
|
through Home Manager.
|
|
|
|
- _This module configures Hyprland and adds it to your user's `$PATH`, but
|
|
|
|
does not make certain system-level changes such as adding a desktop session
|
|
|
|
file for your display manager. This is handled by the NixOS module once you
|
|
|
|
enable it._
|
|
|
|
|
|
|
|
{{< /callout >}}
|
2023-07-17 18:14:43 +02:00
|
|
|
|
2023-12-14 19:02:45 +01:00
|
|
|
## Installation
|
2023-07-17 18:14:43 +02:00
|
|
|
|
2024-05-05 14:56:59 +02:00
|
|
|
{{< tabs items="Home Manager,Flakes,Nix stable (with flake-compat)" >}}
|
2023-07-17 18:14:43 +02:00
|
|
|
|
2023-12-14 19:02:45 +01:00
|
|
|
{{< tab "Home Manager" >}}
|
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="home.nix"}
|
2023-12-14 19:02:45 +01:00
|
|
|
{
|
2024-08-31 11:28:06 +02:00
|
|
|
programs.kitty.enable = true; # required for the default Hyprland config
|
|
|
|
wayland.windowManager.hyprland.enable = true; # enable Hyprland
|
|
|
|
|
|
|
|
# Optional, hint Electron apps to use Wayland:
|
|
|
|
# home.sessionVariables.NIXOS_OZONE_WL = "1";
|
2023-12-14 19:02:45 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
{{< /tab >}}
|
|
|
|
|
2023-07-17 18:14:43 +02:00
|
|
|
{{< tab "Flakes" >}}
|
|
|
|
|
2023-12-14 19:02:45 +01:00
|
|
|
The following snippet of code tries to show how to bring the Hyprland flake from
|
2024-09-01 19:42:51 +02:00
|
|
|
the flake input and use its packages with Home Manager. Feel free to make any
|
2023-12-14 19:02:45 +01:00
|
|
|
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
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="flake.nix"}
|
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";
|
|
|
|
};
|
|
|
|
|
2024-10-10 17:13:46 +02:00
|
|
|
hyprland.url = "github:hyprwm/Hyprland";
|
2022-12-18 14:20:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = {nixpkgs, home-manager, hyprland, ...}: {
|
|
|
|
homeConfigurations."user@hostname" = home-manager.lib.homeManagerConfiguration {
|
|
|
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
|
|
|
|
|
|
|
modules = [
|
2024-06-23 00:46:01 +02:00
|
|
|
{
|
2024-09-01 19:42:51 +02:00
|
|
|
wayland.windowManager.hyprland = {
|
|
|
|
enable = true;
|
|
|
|
# set the flake package
|
|
|
|
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
|
|
|
|
};
|
2024-06-23 00:46:01 +02:00
|
|
|
}
|
2022-12-18 14:20:19 +01:00
|
|
|
# ...
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2022-12-28 16:31:43 +01:00
|
|
|
}
|
2022-12-18 14:20:19 +01:00
|
|
|
```
|
2023-12-14 19:02:45 +01:00
|
|
|
|
2023-07-17 18:14:43 +02:00
|
|
|
{{< /tab >}}
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-09-01 19:42:51 +02:00
|
|
|
{{< tab "Nix stable (with flake-compat)" >}}
|
2023-12-14 19:02:45 +01:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< callout >}}
|
2023-12-14 19:02:45 +01:00
|
|
|
|
|
|
|
The flake module is merely an extension to the Home Manager downstream module.
|
|
|
|
It is mainly used as a staging area for new options, so unless you're a tester
|
|
|
|
you should use the downstream Home Manager module.
|
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< /callout >}}
|
2023-12-14 19:02:45 +01:00
|
|
|
|
|
|
|
The following snippet of code tries to show how to bring the Hyprland flake from
|
2024-05-05 14:56:59 +02:00
|
|
|
the flake input and use the package in the Home Manager option. Feel free to
|
|
|
|
make any adjustment for your setup.
|
2023-12-14 19:02:45 +01:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="home.nix"}
|
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";
|
|
|
|
|
2024-09-01 19:42:51 +02:00
|
|
|
hyprland = (import flake-compat {
|
2024-10-10 17:13:46 +02:00
|
|
|
src = builtins.fetchTarball "https://github.com/hyprwm/Hyprland/archive/main.tar.gz";
|
2022-12-18 14:20:19 +01:00
|
|
|
}).defaultNix;
|
|
|
|
in {
|
2024-05-05 14:56:59 +02:00
|
|
|
wayland.windowManager.hyprland = {
|
|
|
|
enable = true;
|
2024-09-01 19:42:51 +02:00
|
|
|
# set the flake package
|
|
|
|
package = hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
|
2024-05-05 14:56:59 +02:00
|
|
|
}
|
2022-12-18 14:20:19 +01:00
|
|
|
}
|
|
|
|
```
|
2023-12-14 19:02:45 +01:00
|
|
|
|
2023-07-17 18:14:43 +02:00
|
|
|
{{< /tab >}}
|
|
|
|
|
|
|
|
{{< /tabs >}}
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2023-12-14 19:02:45 +01:00
|
|
|
Once the module is enabled, you can use it to declaratively configure Hyprland.
|
2024-06-23 00:46:01 +02:00
|
|
|
Here is an example config:
|
2023-07-17 18:14:43 +02:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="home.nix"}
|
2023-12-14 19:02:45 +01:00
|
|
|
{
|
|
|
|
wayland.windowManager.hyprland.settings = {
|
|
|
|
"$mod" = "SUPER";
|
|
|
|
bind =
|
|
|
|
[
|
|
|
|
"$mod, F, exec, firefox"
|
|
|
|
", Print, exec, grimblast copy area"
|
|
|
|
]
|
|
|
|
++ (
|
|
|
|
# workspaces
|
2024-08-29 21:00:18 +02:00
|
|
|
# binds $mod + [shift +] {1..9} to [move to] workspace {1..9}
|
|
|
|
builtins.concatLists (builtins.genList (i:
|
|
|
|
let ws = i + 1;
|
2023-12-14 19:02:45 +01:00
|
|
|
in [
|
2024-08-29 21:00:18 +02:00
|
|
|
"$mod, code:1${toString i}, workspace, ${toString ws}"
|
|
|
|
"$mod SHIFT, code:1${toString i}, movetoworkspace, ${toString ws}"
|
2023-12-14 19:02:45 +01:00
|
|
|
]
|
|
|
|
)
|
2024-08-29 21:00:18 +02:00
|
|
|
9)
|
2023-12-14 19:02:45 +01:00
|
|
|
);
|
|
|
|
};
|
2023-07-17 18:14:43 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Plugins
|
|
|
|
|
2023-12-14 19:02:45 +01:00
|
|
|
Hyprland plugins can be added through the `plugins` option:
|
2023-07-17 18:14:43 +02:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="home.nix"}
|
2024-06-23 00:46:01 +02:00
|
|
|
{
|
|
|
|
wayland.windowManager.hyprland.plugins = [
|
|
|
|
inputs.hyprland-plugins.packages.${pkgs.stdenv.hostPlatform.system}.hyprbars
|
|
|
|
"/absolute/path/to/plugin.so"
|
|
|
|
];
|
|
|
|
}
|
2023-07-17 18:14:43 +02:00
|
|
|
```
|
|
|
|
|
2024-04-21 16:35:48 +02:00
|
|
|
For examples on how to build Hyprland plugins using Nix, see the
|
2024-06-23 00:46:01 +02:00
|
|
|
[Nix/Plugins](../Plugins) page.
|
2023-10-17 08:04:44 +02:00
|
|
|
|
2024-06-23 00:46:01 +02:00
|
|
|
## FAQ
|
|
|
|
|
|
|
|
### Fixing problems with themes
|
2023-10-17 08:04:44 +02:00
|
|
|
|
2024-04-21 16:35:48 +02:00
|
|
|
If your themes for mouse cursors, icons or windows don't load correctly, try
|
2023-12-14 19:02:45 +01:00
|
|
|
setting them with `home.pointerCursor` and `gtk.theme`, which enable a bunch of
|
|
|
|
compatibility options that should make the themes load in all situations.
|
2023-10-17 08:04:44 +02:00
|
|
|
|
|
|
|
Example configuration:
|
2023-12-14 19:02:45 +01:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="home.nix"}
|
2024-06-23 00:46:01 +02:00
|
|
|
{
|
|
|
|
home.pointerCursor = {
|
|
|
|
gtk.enable = true;
|
|
|
|
# x11.enable = true;
|
|
|
|
package = pkgs.bibata-cursors;
|
|
|
|
name = "Bibata-Modern-Classic";
|
|
|
|
size = 16;
|
2023-12-14 19:02:45 +01:00
|
|
|
};
|
|
|
|
|
2024-06-23 00:46:01 +02:00
|
|
|
gtk = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
theme = {
|
|
|
|
package = pkgs.flat-remix-gtk;
|
|
|
|
name = "Flat-Remix-GTK-Grey-Darkest";
|
|
|
|
};
|
2023-12-14 19:02:45 +01:00
|
|
|
|
2024-06-23 00:46:01 +02:00
|
|
|
iconTheme = {
|
|
|
|
package = pkgs.gnome.adwaita-icon-theme;
|
|
|
|
name = "Adwaita";
|
|
|
|
};
|
|
|
|
|
|
|
|
font = {
|
|
|
|
name = "Sans";
|
|
|
|
size = 11;
|
|
|
|
};
|
2023-10-17 08:04:44 +02:00
|
|
|
};
|
2024-06-23 00:46:01 +02:00
|
|
|
}
|
2023-10-17 08:04:44 +02:00
|
|
|
```
|
2024-04-04 09:29:00 +02:00
|
|
|
|
2024-06-23 00:46:01 +02:00
|
|
|
### Programs don't work in systemd services, but do on the terminal
|
2024-04-04 09:29:00 +02:00
|
|
|
|
2024-04-21 16:35:48 +02:00
|
|
|
This problem is related to systemd not importing the environment by default. It
|
2024-04-04 09:29:00 +02:00
|
|
|
will not have knowledge of `PATH`, so it cannot run the commands in the
|
|
|
|
services. This is the most common with user-configured services such as
|
|
|
|
`hypridle` or `swayidle`.
|
|
|
|
|
|
|
|
To fix it, add to your config:
|
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="home.nix"}
|
2024-04-04 09:29:00 +02:00
|
|
|
wayland.windowManager.hyprland.systemd.variables = ["--all"];
|
|
|
|
```
|
|
|
|
|
|
|
|
This setting will produce the following entry in the Hyprland config:
|
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```ini {filename="hyprland.conf"}
|
2024-04-04 09:29:00 +02:00
|
|
|
exec-once = dbus-update-activation-environment --systemd --all
|
|
|
|
```
|
|
|
|
|
|
|
|
Make sure to use the above command if you do not use the Home Manager module.
|