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

106 lines
2.4 KiB
Markdown
Raw Normal View History

2022-12-18 14:20:19 +01:00
The NixOS module enables critical components needed to run Hyprland properly,
such as: polkit,
[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
2023-04-09 14:02:54 +02:00
## From Nixpkgs
2022-12-18 14:20:19 +01:00
2023-04-09 14:02:54 +02:00
```nix
# configuration.nix
{pkgs, ...}: {
programs.hyprland.enable = true;
}
```
### Using unstable Hyprland
In case you want to use the module from Nixpkgs, but also want the development
version of Hyprland, you can add it like this:
```nix
# 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;
}
```
## From the Flake
2022-12-18 14:20:19 +01:00
```nix
# 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;}
# ...
];
};
};
2022-12-28 16:31:43 +01:00
}
2022-12-18 14:20:19 +01:00
```
Don't forget to replace `HOSTNAME` with your hostname!
2023-04-09 14:02:54 +02:00
## From the Flake, on Nix stable
2022-12-18 14:20:19 +01:00
{{< hint >}}
If you're using Hyprland through an overlay, set
`programs.hyprland.package = pkgs.hyprland;`. This also means the `xwayland`
and `nvidiaPatches` options no longer apply.
{{< /hint >}}
```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
2022-12-18 14:20:19 +01:00
hyprland = (import flake-compat {
src = builtins.fetchTarball "https://github.com/hyprwm/Hyprland/archive/master.tar.gz";
}).defaultNix;
in {
2023-02-14 14:30:40 +01:00
imports = [hyprland.nixosModules.default];
2022-12-18 14:20:19 +01:00
programs.hyprland = {
enable = true;
2023-02-14 14:30:40 +01:00
# default options, you don't need to set them
2022-12-18 14:20:19 +01:00
package = hyprland.packages.${pkgs.system}.default;
2023-02-14 14:30:40 +01:00
xwayland = {
enable = true;
2023-04-09 14:02:54 +02:00
hidpi = false;
2023-02-14 14:30:40 +01:00
};
nvidiaPatches = false;
2022-12-18 14:20:19 +01:00
};
}
```