Nix: revise docs

This commit is contained in:
Mihai Fufezan 2022-12-09 14:38:13 +02:00
parent cacf4442d3
commit 51ec7b739b
No known key found for this signature in database
GPG key ID: 5899325F2F120900

View file

@ -10,6 +10,9 @@ work as intended. Please use the
# Install and configure Hyprland on NixOS # Install and configure Hyprland on NixOS
First of all, it is a good idea to set up [Cachix](#cachix) before enabling
any of the modules/installing Hyprland.
Make sure to check out the options of the Make sure to check out the options of the
[Nix module](https://github.com/hyprwm/Hyprland/blob/main/nix/module.nix). [Nix module](https://github.com/hyprwm/Hyprland/blob/main/nix/module.nix).
@ -23,14 +26,10 @@ As such, installation using the Flake is recommended.
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
hyprland = { hyprland.url = "github:hyprwm/Hyprland";
url = "github:hyprwm/Hyprland";
# build with your own instance of nixpkgs
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { self, nixpkgs, hyprland }: { outputs = {self, nixpkgs, hyprland, ...}: {
nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem { nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
# ... # ...
modules = [ modules = [
@ -81,20 +80,19 @@ You can use the Home Manager module by adding it to your configuration:
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
hyprland = {
url = "github:hyprwm/Hyprland"; hyprland.url = "github:hyprwm/Hyprland";
# build with your own instance of nixpkgs
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { self, nixpkgs, home-manager, hyprland }: { outputs = {self, nixpkgs, home-manager, hyprland, ...}: {
homeConfigurations."USER@HOSTNAME"= home-manager.lib.homeManagerConfiguration { homeConfigurations."user@hostname" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [ modules = [
hyprland.homeManagerModules.default hyprland.homeManagerModules.default
{wayland.windowManager.hyprland.enable = true;} {wayland.windowManager.hyprland.enable = true;}
@ -104,7 +102,7 @@ You can use the Home Manager module by adding it to your configuration:
}; };
``` ```
Don't forget to replace `USER@HOSTNAME` with your username and hostname! Don't forget to replace `user@hostname` with your username and hostname!
## Without flakes ## Without flakes
@ -112,6 +110,7 @@ Don't forget to replace `USER@HOSTNAME` with your username and hostname!
# home config # home config
{config, pkgs, inputs, ...}: let {config, pkgs, inputs, ...}: let
flake-compat = builtins.fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz"; flake-compat = builtins.fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz";
hyprland = (import flake-compat { hyprland = (import flake-compat {
src = builtins.fetchTarball "https://github.com/hyprwm/Hyprland/archive/master.tar.gz"; src = builtins.fetchTarball "https://github.com/hyprwm/Hyprland/archive/master.tar.gz";
}).defaultNix; }).defaultNix;
@ -130,8 +129,8 @@ For a list of available options, check the
# Modules mix'n'match # Modules mix'n'match
- If you plan on using the HM module alongside the NixOS module, set the NixOS - If you're on NixOS and also use HM it's a good idea to use Hyprland modules
`programs.hyprland.package = null;`. for both. Make sure the package options are the same for both modules.
- If you don't plan on using the NixOS module, but want to use the HM module, you - If you don't plan on using the NixOS module, but want to use the HM module, you
will have to enable all the options the NixOS module enables. will have to enable all the options the NixOS module enables.
@ -185,7 +184,7 @@ command documentation for other upgrade options.
# XWayland # XWayland
XWayland is enabled by default in the Nix package. You can disable it either XWayland is enabled by default in the Nix package. You can disable it either
in the package itself, or through the Home Manager module. in the package itself, or through the module options.
## Package ## Package
@ -204,6 +203,15 @@ wayland.windowManager.hyprland = {
} }
``` ```
### NixOS module
```nix
programs.hyprland = {
enable = true;
xwayland.enable = false;
}
```
## HiDPI ## HiDPI
By default, the Nix package includes a patched wlroots that can render HiDPI By default, the Nix package includes a patched wlroots that can render HiDPI
@ -215,7 +223,7 @@ In order to enable the functionality, you have to add:
exec-once=xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2 exec-once=xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2
``` ```
This will make XWL programs look as if they were unscaled. To fix this, you This will make XWayland programs look as if they were unscaled. To fix this, you
have to export different environment variables to make the specific toolkits have to export different environment variables to make the specific toolkits
render at the proper scaling. For example render at the proper scaling. For example
@ -238,11 +246,24 @@ or by passing the `hidpiXWayland = false;` flag, the same way as
# Cachix # Cachix
A [Hyprland Cachix](https://app.cachix.org/cache/hyprland) exists to cache the Hyprland often needs dependencies which aren't yet cached in `cache.nixos.org`.
`wlroots` package and speed up builds. Instead of requiring you to build those dependencies (which may include `mesa`,
`ffmpeg`, etc), we provide a Cachix cache that you can add to your Nix
substituters.
In case you don't plan on changing the Nixpkgs input of Hyprland, you can use The [Hyprland Cachix](https://app.cachix.org/cache/hyprland) exists to cache the
this cache to download the binary directly, instead of building locally. `hyprland` packages and any dependencies not found in `cache.nixos.org`.
{{< hint >}}
In order for Nix to take advantage of the cache, it has to be enabled **before**
enabling the Hyprland module(s) or adding the package.
{{< /hint >}}
{{< hint type=important >}}
Overriding Hyprland's `nixpkgs` input
(`inputs.hyprland.inputs.nixpkgs.follows = "nixpkgs";`) will make the cache
useless, since you're building from a different Nixpkgs commit.
{{< /hint >}}
```nix ```nix
# configuration.nix # configuration.nix