Hyprland on Nix Os
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.
# configuration.nix
{pkgs, ...}: {
programs.hyprland.enable = true;
}
In case you want to use the module from Nixpkgs, but also want 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.package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
}
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
hyprland.url = "github:hyprwm/Hyprland";
};
outputs = {nixpkgs, hyprland, ...}: {
nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
modules = [
hyprland.nixosModules.default
{programs.hyprland.enable = true;}
# ...
];
};
};
}
Don’t forget to replace HOSTNAME
with your hostname!
If you’re using Hyprland through an overlay, setprograms.hyprland.package = pkgs.hyprland;
. This also means thexwayland
andnvidiaPatches
options no longer apply.
# configuration.nix
{pkgs, ...}: let
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.nixosModules.default];
programs.hyprland = {
enable = true;
# default options, you don't need to set them
package = hyprland.packages.${pkgs.system}.default;
xwayland = {
enable = true;
hidpi = false;
};
nvidiaPatches = false;
};
}