2024-02-20 21:16:07 +01:00
|
|
|
---
|
|
|
|
title: Hyprland on NixOS
|
|
|
|
---
|
|
|
|
|
2022-12-18 14:20:19 +01:00
|
|
|
The NixOS module enables critical components needed to run Hyprland properly,
|
2024-06-23 00:46:01 +02:00
|
|
|
such as polkit,
|
2022-12-18 14:20:19 +01:00
|
|
|
[xdg-desktop-portal-hyprland](https://github.com/hyprwm/xdg-desktop-portal-hyprland),
|
|
|
|
graphics drivers, fonts, dconf, xwayland, and adding a proper Desktop Entry to
|
|
|
|
your Display Manager.
|
|
|
|
|
|
|
|
Make sure to check out the options of the
|
2023-04-09 14:02:54 +02:00
|
|
|
[NixOS module](https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=hyprland).
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< callout >}}
|
|
|
|
|
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._
|
2024-02-20 21:16:07 +01:00
|
|
|
|
|
|
|
{{< /callout >}}
|
2023-09-04 17:46:31 +02:00
|
|
|
|
2024-05-05 14:56:59 +02:00
|
|
|
{{< tabs items="Nixpkgs,Flakes,Nix stable (flake-compat)" >}}
|
2023-07-17 18:14:43 +02:00
|
|
|
|
|
|
|
{{< tab "Nixpkgs" >}}
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="configuration.nix"}
|
2024-06-23 00:46:01 +02:00
|
|
|
{
|
2024-09-17 14:03:07 +02:00
|
|
|
programs.hyprland.enable = true; # enable Hyprland
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
# ... other packages
|
|
|
|
pkgs.kitty # required for the default Hyprland config
|
|
|
|
];
|
2024-08-31 11:28:06 +02:00
|
|
|
|
|
|
|
# Optional, hint Electron apps to use Wayland:
|
|
|
|
# environment.sessionVariables.NIXOS_OZONE_WL = "1";
|
2023-04-09 14:02:54 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-06-23 00:46:01 +02:00
|
|
|
This will use the Hyprland version included in the Nixpkgs release you're using.
|
2023-07-17 18:14:43 +02:00
|
|
|
|
|
|
|
{{< /tab >}}
|
|
|
|
|
2024-05-05 14:56:59 +02:00
|
|
|
{{< tab "Flake Package" >}}
|
2023-07-17 18:14:43 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< callout >}}
|
|
|
|
|
2024-03-17 13:44:39 +01:00
|
|
|
Please enable [Cachix](../Cachix) before using the flake package, so you don't
|
2023-07-17 18:14:43 +02:00
|
|
|
have to compile Hyprland yourself.
|
2023-04-09 14:02:54 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< /callout >}}
|
|
|
|
|
|
|
|
In case you want to use the development version of Hyprland, you can add it like
|
|
|
|
this:
|
2023-04-09 14:02:54 +02:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="flake.nix"}
|
2023-04-09 14:02:54 +02:00
|
|
|
{
|
2024-10-10 17:13:46 +02:00
|
|
|
inputs.hyprland.url = "github:hyprwm/Hyprland";
|
2023-04-09 14:02:54 +02:00
|
|
|
# ...
|
|
|
|
|
|
|
|
outputs = {nixpkgs, ...} @ inputs: {
|
|
|
|
nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
|
2023-07-17 18:14:43 +02:00
|
|
|
specialArgs = { inherit inputs; }; # this is the important part
|
|
|
|
modules = [
|
|
|
|
./configuration.nix
|
|
|
|
];
|
2023-04-09 14:02:54 +02:00
|
|
|
};
|
2024-05-16 20:22:05 +02:00
|
|
|
};
|
2023-04-09 14:02:54 +02:00
|
|
|
}
|
2024-11-06 21:55:14 +01:00
|
|
|
```
|
2023-04-09 14:02:54 +02:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="configuration.nix"}
|
2023-04-09 14:02:54 +02:00
|
|
|
{inputs, pkgs, ...}: {
|
2023-07-17 18:14:43 +02:00
|
|
|
programs.hyprland = {
|
|
|
|
enable = true;
|
2024-09-01 19:42:51 +02:00
|
|
|
# set the flake package
|
2024-06-23 00:46:01 +02:00
|
|
|
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
|
2024-09-01 19:42:51 +02:00
|
|
|
# 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;
|
2022-12-18 14:20:19 +01:00
|
|
|
};
|
2022-12-28 16:31:43 +01:00
|
|
|
}
|
2022-12-18 14:20:19 +01:00
|
|
|
```
|
2024-02-20 21:16:07 +01:00
|
|
|
|
2023-07-17 18:14:43 +02:00
|
|
|
Don't forget to change the `HOSTNAME` to your actual hostname!
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-03-17 21:02:59 +01:00
|
|
|
If you start experiencing lag and FPS drops in games or programs like Blender on
|
2024-06-23 00:46:01 +02:00
|
|
|
**stable** NixOS when using the Hyprland flake, it is most likely a `mesa`
|
2024-03-17 21:02:59 +01:00
|
|
|
version mismatch between your system and Hyprland.
|
|
|
|
|
|
|
|
You can fix this issue by using `mesa` from Hyprland's `nixpkgs` input:
|
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="configuration.nix"}
|
2024-03-17 21:02:59 +01:00
|
|
|
{pkgs, inputs, ...}: let
|
|
|
|
pkgs-unstable = inputs.hyprland.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system};
|
|
|
|
in {
|
|
|
|
hardware.opengl = {
|
|
|
|
package = pkgs-unstable.mesa.drivers;
|
|
|
|
|
|
|
|
# if you also want 32-bit support (e.g for Steam)
|
|
|
|
driSupport32Bit = true;
|
|
|
|
package32 = pkgs-unstable.pkgsi686Linux.mesa.drivers;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
For more details, see
|
|
|
|
[issue #5148](https://github.com/hyprwm/Hyprland/issues/5148).
|
|
|
|
|
2023-07-17 18:14:43 +02:00
|
|
|
{{< /tab >}}
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-05-05 14:56:59 +02:00
|
|
|
{{< tab "Nix stable" >}}
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< callout >}}
|
|
|
|
|
2024-03-17 13:44:39 +01:00
|
|
|
Please enable [Cachix](../Cachix) before using the flake package, so you don't
|
2023-07-17 18:14:43 +02:00
|
|
|
have to compile Hyprland yourself.
|
2024-02-20 21:16:07 +01:00
|
|
|
|
|
|
|
{{< /callout >}}
|
2022-12-18 14:20:19 +01:00
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```nix {filename="configuration.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";
|
2023-02-14 14:30:40 +01:00
|
|
|
|
2024-05-05 14:56:59 +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 {
|
|
|
|
programs.hyprland = {
|
|
|
|
enable = true;
|
2024-09-01 19:42:51 +02:00
|
|
|
# set the flake package
|
2024-06-23 00:46:01 +02:00
|
|
|
package = hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
|
2024-09-01 19:42:51 +02:00
|
|
|
# make sure to also set the portal package, so that they are in sync
|
|
|
|
portalPackage = hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
|
2022-12-18 14:20:19 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
2023-07-17 18:14:43 +02:00
|
|
|
|
|
|
|
{{< /tab >}}
|
2024-02-20 21:16:07 +01:00
|
|
|
|
2023-07-17 18:14:43 +02:00
|
|
|
{{< /tabs >}}
|
2023-10-17 08:04:44 +02:00
|
|
|
|
|
|
|
## Fixing problems with themes
|
|
|
|
|
2024-04-21 16:35:48 +02:00
|
|
|
If your themes for mouse cursors, icons or windows don't load correctly, see the
|
2024-03-17 13:44:39 +01:00
|
|
|
relevant section in [Hyprland on Home Manager](../Hyprland-on-Home-Manager).
|
2024-08-29 22:41:27 +02:00
|
|
|
|
|
|
|
If you prefer not to use Home Manager, you can also resolve the issues with GTK
|
|
|
|
themes using dconf like so:
|
|
|
|
|
2024-11-06 21:55:14 +01:00
|
|
|
```ini {filename="hyprland.conf"}
|
2024-08-29 22:41:27 +02:00
|
|
|
exec-once = dconf write /org/gnome/desktop/interface/gtk-theme "'Adwaita'"
|
|
|
|
exec-once = dconf write /org/gnome/desktop/interface/icon-theme "'Flat-Remix-Red-Dark'"
|
|
|
|
exec-once = dconf write /org/gnome/desktop/interface/document-font-name "'Noto Sans Medium 11'"
|
|
|
|
exec-once = dconf write /org/gnome/desktop/interface/font-name "'Noto Sans Medium 11'"
|
|
|
|
exec-once = dconf write /org/gnome/desktop/interface/monospace-font-name "'Noto Sans Mono Medium 11'"
|
|
|
|
```
|