hyprland-wiki/pages/Nix/Hyprland on NixOS.md
Mihai Fufezan 127ae00225 wiki: prepare for hextra
treewide: replace hint with callout

treewide: remove ToC header

remove <toc>, since it's autogenerated
add missing _index.md

treewide: add frontmatter

treewide: fix headings

add weights

Configuring,Getting Started: expand in sidebar

Add version selector

fix links
2024-03-14 22:47:27 +02:00

2.5 KiB

title
Hyprland on NixOS

The NixOS module enables critical components needed to run Hyprland properly, such as: polkit, 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 NixOS module.

{{< callout >}}

  • (Required) NixOS Module: enables critical components needed to run Hyprland properly
  • (Optional) Home-manager module: lets you declaratively configure Hyprland

{{< /callout >}}

{{< tabs items="Nixpkgs,Flake Package, No Flakes (with flake-compat)" >}}

{{< tab "Nixpkgs" >}}

# configuration.nix

{pkgs, ...}: {
  programs.hyprland.enable = true;
}

This will use the Hyprland version that Nixpkgs has.

{{< /tab >}}

{{< tab "Flake package" >}}

{{< callout >}}

Please enable Cachix before using the flake package, so you don't have to compile Hyprland yourself.

{{< /callout >}}

In case you want to use the development version of Hyprland, you can add it like this:

# flake.nix

{
  inputs.hyprland.url = "github:hyprwm/Hyprland";
  # ...

  outputs = {nixpkgs, ...} @ inputs: {
    nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
      specialArgs = { inherit inputs; }; # this is the important part
      modules = [
        ./configuration.nix
      ];
    };
  } 
}

# configuration.nix

{inputs, pkgs, ...}: {
  programs.hyprland = {
    enable = true;
    package = inputs.hyprland.packages.${pkgs.system}.hyprland;
  };
}

Don't forget to change the HOSTNAME to your actual hostname!

{{< /tab >}}

{{< tab "Flake package, Nix stable" >}}

{{< callout >}}

Please enable Cachix before using the flake package, so you don't have to compile Hyprland yourself.

{{< /callout >}}

# configuration.nix

{pkgs, ...}: let
  flake-compat = builtins.fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz";

  hyprland-flake = (import flake-compat {
    src = builtins.fetchTarball "https://github.com/hyprwm/Hyprland/archive/master.tar.gz";
  }).defaultNix;
in {
  programs.hyprland = {
    enable = true;
    package = hyprland-flake.packages.${pkgs.system}.hyprland;
  };
}

{{< /tab >}}

{{< /tabs >}}

Fixing problems with themes

If your themes for mouse cursor, icons or windows don't load correctly, see the relevant section in Hyprland on Home Manager.