hyprland-wiki/pages/Nix/_index.md

149 lines
3.7 KiB
Markdown
Raw Normal View History

2022-08-13 19:06:18 +02:00
## Table of contents
{{< toc format=html >}}
2022-08-12 20:46:36 +02:00
**NOTE:** Hyprland is NOT supported on NixOS stable. It may (not) compile or
2022-08-13 19:06:18 +02:00
work as intended. Please use the
[flake](https://github.com/hyprwm/Hyprland/blob/main/flake.nix).
2022-08-12 20:46:36 +02:00
2022-08-13 19:06:18 +02:00
## Install and configure Hyprland on NixOS
2022-08-12 20:46:36 +02:00
Make sure to check out the options of the
[Nix module](https://github.com/hyprwm/Hyprland/blob/main/nix/module.nix).
### With flakes
```nix
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
hyprland = {
url = "github:hyprwm/Hyprland";
# build with your own instance of nixpkgs
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, hyprland }: {
nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
# ...
modules = [
hyprland.nixosModules.default
{ programs.hyprland.enable = true; }
# ...
];
};
};
```
Don't forget to replace `HOSTNAME` with your hostname!
### Without flakes
2022-08-13 19:06:18 +02:00
{{< hint >}}
If you're using Hyprland through an overlay, set
2022-08-12 20:46:36 +02:00
`programs.hyprland.package = pkgs.hyprland;`.
2022-08-13 19:06:18 +02:00
{{< /hint >}}
2022-08-12 20:46:36 +02:00
```nix
# configuration.nix
{config, 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
];
2022-08-13 19:06:18 +02:00
2022-08-12 20:46:36 +02:00
programs.hyprland = {
enable = true;
2022-08-13 19:06:18 +02:00
package = hyprland.packages.${pkgs.system}.default;
2022-08-12 20:46:36 +02:00
};
}
```
2022-08-13 19:06:18 +02:00
## Install and configure through Home Manager
2022-08-12 20:46:36 +02:00
You can use the Home Manager module by adding it to your configuration:
```nix
{ config, pkgs, inputs, ... }: {
imports = [
inputs.hyprland.homeManagerModules.default
];
wayland.windowManager.hyprland.enable = true;
# ...
}
```
For a list of available options, check the
[module file](https://github.com/hyprwm/Hyprland/blob/main/nix/hm-module.nix).
## Modules mix'n'match
2022-08-13 19:06:18 +02:00
- If you plan on using the HM module alongside the NixOS module, set the NixOS
2022-08-12 20:46:36 +02:00
`programs.hyprland.package = null;`.
2022-08-13 19:06:18 +02:00
- If you don't plan on using the NixOS module, but want to use the HM module, you
2022-08-12 20:46:36 +02:00
will have to enable all the options the NixOS module enables.
2022-08-13 19:06:18 +02:00
- If you don't plan on using any module, manually enable whatever options the
2022-08-12 20:46:36 +02:00
modules set.
2022-08-13 19:06:18 +02:00
## Non-NixOS install
2022-08-26 19:04:30 +02:00
### With flakes
First, [enable flakes](https://nixos.wiki/wiki/Flakes#Enable_flakes).
Once you have flakes working, install Hyprland through `nix profile`:
```sh
$ nix profile install github:hyprwm/Hyprland
```
Since you're using Hyprland outside of NixOS, it won't be able to find graphics
drivers. To get around that, you can use [nixGL](https://github.com/guibou/nixGL).
First, install it, in the same manner you installed Hyprland:
```sh
$ nix profile install github:guibou/nixGL
```
From now on, you can run Hyprland by invoking it with nixGL
```sh
$ nixGL Hyprland
```
or by creating a wrapper script that runs the above command inside.
### Upgrading
2022-08-26 19:10:44 +02:00
In order to upgrade all your packages, you can run
2022-08-26 19:04:30 +02:00
```sh
$ nix profile upgrade '.*'
```
Check the
[nix profile](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-profile.html)
command documentation for other upgrade options.
2022-08-13 19:06:18 +02:00
2022-08-12 20:46:36 +02:00
## Cachix
2022-08-13 19:06:18 +02:00
A [Hyprland Cachix](https://app.cachix.org/cache/hyprland) exists to cache the
2022-08-13 01:47:48 +02:00
`wlroots` package and speed up builds.
2022-08-12 20:46:36 +02:00
2022-08-13 19:06:18 +02:00
In case you don't plan on changing the Nixpkgs input of Hyprland, you can use
this cache to download the binary directly, instead of building locally.
2022-08-12 20:46:36 +02:00
```nix
# configuration.nix
{
nix.settings = {
substituters = ["https://hyprland.cachix.org"];
trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
};
}
```