hyprland-wiki/pages/Nix/Hyprland on NixOS.md

143 lines
3.5 KiB
Markdown
Raw Normal View History

---
title: Hyprland on NixOS
---
2022-12-18 14:20:19 +01:00
The NixOS module enables critical components needed to run Hyprland properly,
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
{{< callout >}}
- _(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 declaratively configure Hyprland
{{< /callout >}}
2024-05-05 14:56:59 +02:00
{{< tabs items="Nixpkgs,Flakes,Nix stable (flake-compat)" >}}
{{< tab "Nixpkgs" >}}
2022-12-18 14:20:19 +01:00
2023-04-09 14:02:54 +02:00
```nix
# configuration.nix
{
2023-04-09 14:02:54 +02:00
programs.hyprland.enable = true;
}
```
This will use the Hyprland version included in the Nixpkgs release you're using.
{{< /tab >}}
2024-05-05 14:56:59 +02:00
{{< tab "Flake Package" >}}
{{< callout >}}
2024-03-17 13:44:39 +01:00
Please enable [Cachix](../Cachix) before using the flake package, so you don't
have to compile Hyprland yourself.
2023-04-09 14:02:54 +02: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
```nix
# flake.nix
{
2024-05-05 14:56:59 +02:00
inputs.hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1";
2023-04-09 14:02:54 +02:00
# ...
outputs = {nixpkgs, ...} @ inputs: {
nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; }; # this is the important part
modules = [
./configuration.nix
];
2023-04-09 14:02:54 +02:00
};
};
2023-04-09 14:02:54 +02:00
}
# configuration.nix
{inputs, pkgs, ...}: {
programs.hyprland = {
enable = true;
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.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
```
Don't forget to change the `HOSTNAME` to your actual hostname!
2022-12-18 14:20:19 +01:00
If you start experiencing lag and FPS drops in games or programs like Blender on
**stable** NixOS when using the Hyprland flake, it is most likely a `mesa`
version mismatch between your system and Hyprland.
You can fix this issue by using `mesa` from Hyprland's `nixpkgs` input:
```nix
{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).
{{< /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
{{< callout >}}
2024-03-17 13:44:39 +01:00
Please enable [Cachix](../Cachix) before using the flake package, so you don't
have to compile Hyprland yourself.
{{< /callout >}}
2022-12-18 14:20:19 +01:00
```nix
# 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 {
# we're not using pkgs.fetchgit as that requires a hash to be provided
src = builtins.fetchGit {
url = "https://github.com/hyprwm/Hyprland.git";
submodules = true;
};
2022-12-18 14:20:19 +01:00
}).defaultNix;
in {
programs.hyprland = {
enable = true;
package = hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
2022-12-18 14:20:19 +01:00
};
}
```
{{< /tab >}}
{{< /tabs >}}
## Fixing problems with themes
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).