mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 14:45:59 +01:00
nix/*module: use mdDoc for documentation
Simplify and add more info to the docs.
This commit is contained in:
parent
7faead75bd
commit
16d05a5c8b
3 changed files with 124 additions and 138 deletions
|
@ -105,7 +105,11 @@ in
|
|||
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
|
||||
substituteInPlace meson.build \
|
||||
--replace "@GIT_COMMIT_HASH@" '${commit}' \
|
||||
--replace "@GIT_DIRTY@" '${if commit == "" then "dirty" else ""}'
|
||||
--replace "@GIT_DIRTY@" '${
|
||||
if commit == ""
|
||||
then "dirty"
|
||||
else ""
|
||||
}'
|
||||
'';
|
||||
|
||||
passthru.providedSessions = ["hyprland"];
|
||||
|
|
|
@ -8,20 +8,42 @@ self: {
|
|||
defaultHyprlandPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
|
||||
enableXWayland = cfg.xwayland.enable;
|
||||
hidpiXWayland = cfg.xwayland.hidpi;
|
||||
nvidiaPatches = cfg.nvidiaPatches;
|
||||
inherit (cfg) nvidiaPatches;
|
||||
};
|
||||
in {
|
||||
meta.maintainers = [lib.maintainers.fufexan];
|
||||
|
||||
options.wayland.windowManager.hyprland = {
|
||||
enable = lib.mkEnableOption "hyprland wayland compositor";
|
||||
enable =
|
||||
lib.mkEnableOption null
|
||||
// {
|
||||
description = lib.mdDoc ''
|
||||
Whether to enable Hyprland, the dynamic tiling Wayland compositor
|
||||
that doesn't sacrifice on its looks.
|
||||
|
||||
You can manually launch Hyprland by executing {command}`Hyprland` on
|
||||
a TTY.
|
||||
|
||||
See <https://wiki.hyprland.org> for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
package = lib.mkOption {
|
||||
type = with lib.types; nullOr package;
|
||||
default = defaultHyprlandPackage;
|
||||
description = ''
|
||||
Hyprland package to use. Will override the 'xwayland' option.
|
||||
defaultText = lib.literalExpression ''
|
||||
hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
|
||||
enableXWayland = config.wayland.windowManager.hyprland.xwayland.enable;
|
||||
hidpiXWayland = config.wayland.windowManager.hyprland.xwayland.hidpi;
|
||||
inherit (config.wayland.windowManager.hyprland) nvidiaPatches;
|
||||
}
|
||||
'';
|
||||
description = lib.mdDoc ''
|
||||
Hyprland package to use. Will override the 'xwayland' and
|
||||
'nvidiaPatches' options.
|
||||
|
||||
Defaults to the one provided by the flake. Set it to
|
||||
<literal>pkgs.hyprland</literal> to use the one provided by nixpkgs or
|
||||
{package}`pkgs.hyprland` to use the one provided by nixpkgs or
|
||||
if you have an overlay.
|
||||
|
||||
Set to null to not add any Hyprland package to your path. This should
|
||||
|
@ -32,83 +54,56 @@ in {
|
|||
systemdIntegration = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = pkgs.stdenv.isLinux;
|
||||
description = ''
|
||||
Whether to enable <filename>hyprland-session.target</filename> on
|
||||
hyprland startup. This links to <filename>graphical-session.target</filename>.
|
||||
description = lib.mdDoc ''
|
||||
Whether to enable {file}`hyprland-session.target` on
|
||||
hyprland startup. This links to {file}`graphical-session.target`.
|
||||
Some important environment variables will be imported to systemd
|
||||
and dbus user environment before reaching the target, including
|
||||
<itemizedlist>
|
||||
<listitem><para><literal>DISPLAY</literal></para></listitem>
|
||||
<listitem><para><literal>WAYLAND_DISPLAY</literal></para></listitem>
|
||||
<listitem><para><literal>HYPRLAND_INSTANCE_SIGNATURE</literal></para></listitem>
|
||||
<listitem><para><literal>XDG_CURRENT_DESKTOP</literal></para></listitem>
|
||||
</itemizedlist>
|
||||
- {env}`DISPLAY`
|
||||
- {env}`HYPRLAND_INSTANCE_SIGNATURE`
|
||||
- {env}`WAYLAND_DISPLAY`
|
||||
- {env}`XDG_CURRENT_DESKTOP`
|
||||
'';
|
||||
};
|
||||
|
||||
disableAutoreload = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
defaultText = lib.literalExpression "false";
|
||||
example = lib.literalExpression "true";
|
||||
description = ''
|
||||
Whether to disable automatically reloading Hyprland's configuration when
|
||||
rebuilding the Home Manager profile.
|
||||
'';
|
||||
};
|
||||
disableAutoreload =
|
||||
lib.mkEnableOption null
|
||||
// {
|
||||
description = lib.mdDoc ''
|
||||
Whether to disable automatically reloading Hyprland's configuration when
|
||||
rebuilding the Home Manager profile.
|
||||
'';
|
||||
};
|
||||
|
||||
xwayland = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Enable XWayland.
|
||||
'';
|
||||
};
|
||||
hidpi = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable HiDPI XWayland.
|
||||
'';
|
||||
};
|
||||
enable = lib.mkEnableOption (lib.mdDoc "XWayland") // {default = true;};
|
||||
hidpi =
|
||||
lib.mkEnableOption null
|
||||
// {
|
||||
description = lib.mdDoc ''
|
||||
Enable HiDPI XWayland, based on [XWayland MR 733](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733).
|
||||
See <https://wiki.hyprland.org/Nix/Options-Overrides/#xwayland-hidpi> for more info.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nvidiaPatches = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
defaultText = lib.literalExpression "false";
|
||||
example = lib.literalExpression "true";
|
||||
description = ''
|
||||
Patch wlroots for better Nvidia support.
|
||||
'';
|
||||
};
|
||||
nvidiaPatches = lib.mkEnableOption (lib.mdDoc "patching wlroots for better Nvidia support.");
|
||||
|
||||
extraConfig = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra configuration lines to add to ~/.config/hypr/hyprland.conf.
|
||||
description = lib.mdDoc ''
|
||||
Extra configuration lines to add to {file}`~/.config/hypr/hyprland.conf`.
|
||||
'';
|
||||
};
|
||||
|
||||
recommendedEnvironment = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
defaultText = lib.literalExpression "true";
|
||||
example = lib.literalExpression "false";
|
||||
description = ''
|
||||
Whether to set the recommended environment variables.
|
||||
'';
|
||||
};
|
||||
|
||||
imports = [
|
||||
(
|
||||
lib.mkRenamedOptionModule
|
||||
["wayland" "windowManager" "hyprland" "xwayland"]
|
||||
["wayland" "windowManager" "hyprland" "xwayland" "enable"]
|
||||
)
|
||||
];
|
||||
recommendedEnvironment =
|
||||
lib.mkEnableOption null
|
||||
// {
|
||||
description = lib.mdDoc ''
|
||||
Whether to set the recommended environment variables.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
@ -116,9 +111,8 @@ in {
|
|||
lib.optional (cfg.package != null) cfg.package
|
||||
++ lib.optional cfg.xwayland.enable pkgs.xwayland;
|
||||
|
||||
home.sessionVariables = lib.mkIf cfg.recommendedEnvironment {
|
||||
NIXOS_OZONE_WL = "1";
|
||||
};
|
||||
home.sessionVariables =
|
||||
lib.mkIf cfg.recommendedEnvironment {NIXOS_OZONE_WL = "1";};
|
||||
|
||||
xdg.configFile."hypr/hyprland.conf" = lib.mkIf (cfg.extraConfig != null) {
|
||||
text =
|
||||
|
@ -133,13 +127,15 @@ in {
|
|||
then defaultHyprlandPackage
|
||||
else cfg.package;
|
||||
in
|
||||
lib.mkIf (!cfg.disableAutoreload) ''( # execute in subshell so that `shopt` won't affect other scripts
|
||||
shopt -s nullglob # so that nothing is done if /tmp/hypr/ does not exist or is empty
|
||||
for instance in /tmp/hypr/*; do
|
||||
HYPRLAND_INSTANCE_SIGNATURE=''${instance##*/} ${hyprlandPackage}/bin/hyprctl reload config-only \
|
||||
|| true # ignore dead instance(s)
|
||||
done
|
||||
)'';
|
||||
lib.mkIf (!cfg.disableAutoreload) ''
|
||||
( # execute in subshell so that `shopt` won't affect other scripts
|
||||
shopt -s nullglob # so that nothing is done if /tmp/hypr/ does not exist or is empty
|
||||
for instance in /tmp/hypr/*; do
|
||||
HYPRLAND_INSTANCE_SIGNATURE=''${instance##*/} ${hyprlandPackage}/bin/hyprctl reload config-only \
|
||||
|| true # ignore dead instance(s)
|
||||
done
|
||||
)
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.user.targets.hyprland-session = lib.mkIf cfg.systemdIntegration {
|
||||
|
@ -151,12 +147,5 @@ in {
|
|||
After = ["graphical-session-pre.target"];
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.targets.tray = {
|
||||
Unit = {
|
||||
Description = "Home Manager System Tray";
|
||||
Requires = ["graphical-session-pre.target"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
101
nix/module.nix
101
nix/module.nix
|
@ -1,4 +1,3 @@
|
|||
# Copied from https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/programs/sway.nix
|
||||
inputs: {
|
||||
config,
|
||||
lib,
|
||||
|
@ -11,88 +10,82 @@ with lib; let
|
|||
defaultHyprlandPackage = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
|
||||
enableXWayland = cfg.xwayland.enable;
|
||||
hidpiXWayland = cfg.xwayland.hidpi;
|
||||
nvidiaPatches = cfg.nvidiaPatches;
|
||||
inherit (cfg) nvidiaPatches;
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
(mkRemovedOptionModule ["programs" "hyprland" "extraPackages"] "extraPackages has been removed. Use environment.systemPackages instead.")
|
||||
];
|
||||
# disables Nixpkgs Hyprland module to avoid conflicts
|
||||
disabledModules = ["programs/hyprland.nix"];
|
||||
|
||||
options.programs.hyprland = {
|
||||
enable = mkEnableOption ''
|
||||
Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
|
||||
You can manually launch Hyprland by executing "exec Hyprland" on a TTY.
|
||||
A configuration file will be generated in ~/.config/hypr/hyprland.conf.
|
||||
See <link xlink:href="https://github.com/vaxerski/Hyprland/wiki" /> for
|
||||
more information.
|
||||
'';
|
||||
enable =
|
||||
mkEnableOption null
|
||||
// {
|
||||
description = mdDoc ''
|
||||
Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
|
||||
|
||||
You can manually launch Hyprland by executing {command}`Hyprland` on a TTY.
|
||||
|
||||
A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
|
||||
See <https://wiki.hyprland.org> for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.nullOr types.package;
|
||||
type = types.path;
|
||||
default = defaultHyprlandPackage;
|
||||
defaultText = literalExpression "<Hyprland flake>.packages.<system>.default";
|
||||
example = literalExpression "<Hyprland flake>.packages.<system>.default.override { }";
|
||||
description = ''
|
||||
Hyprland package to use.
|
||||
defaultText = literalExpression ''
|
||||
hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
|
||||
enableXWayland = config.programs.hyprland.xwayland.enable;
|
||||
hidpiXWayland = config.programs.hyprland.xwayland.hidpi;
|
||||
inherit (config.programs.hyprland) nvidiaPatches;
|
||||
}
|
||||
'';
|
||||
example = literalExpression "pkgs.hyprland";
|
||||
description = mdDoc ''
|
||||
The Hyprland package to use.
|
||||
Setting this option will make {option}`programs.hyprland.xwayland` and
|
||||
{option}`programs.hyprland.nvidiaPatches` not work.
|
||||
'';
|
||||
};
|
||||
|
||||
xwayland = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Enable XWayland.
|
||||
'';
|
||||
};
|
||||
hidpi = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable HiDPI XWayland.
|
||||
'';
|
||||
};
|
||||
enable = mkEnableOption (mdDoc "XWayland") // {default = true;};
|
||||
hidpi =
|
||||
mkEnableOption null
|
||||
// {
|
||||
description = mdDoc ''
|
||||
Enable HiDPI XWayland, based on [XWayland MR 733](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733).
|
||||
See <https://wiki.hyprland.org/Nix/Options-Overrides/#xwayland-hidpi> for more info.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nvidiaPatches = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = literalExpression "true";
|
||||
description = ''
|
||||
Patch wlroots for better Nvidia support.
|
||||
'';
|
||||
};
|
||||
|
||||
recommendedEnvironment = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
defaultText = literalExpression "true";
|
||||
example = literalExpression "false";
|
||||
description = ''
|
||||
Whether to set the recommended environment variables.
|
||||
'';
|
||||
};
|
||||
nvidiaPatches = mkEnableOption (mdDoc "patching wlroots for better Nvidia support");
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment = {
|
||||
systemPackages = lib.optional (cfg.package != null) cfg.package;
|
||||
systemPackages = [cfg.package];
|
||||
|
||||
sessionVariables = mkIf cfg.recommendedEnvironment {
|
||||
NIXOS_OZONE_WL = "1";
|
||||
sessionVariables = {
|
||||
NIXOS_OZONE_WL = mkDefault "1";
|
||||
};
|
||||
};
|
||||
|
||||
fonts.enableDefaultFonts = mkDefault true;
|
||||
hardware.opengl.enable = mkDefault true;
|
||||
|
||||
programs = {
|
||||
dconf.enable = mkDefault true;
|
||||
xwayland.enable = mkDefault true;
|
||||
};
|
||||
|
||||
security.polkit.enable = true;
|
||||
services.xserver.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
|
||||
|
||||
services.xserver.displayManager.sessionPackages = [cfg.package];
|
||||
|
||||
xdg.portal = {
|
||||
enable = mkDefault true;
|
||||
# xdg-desktop-portal-hyprland
|
||||
extraPortals = lib.mkIf (cfg.package != null) [
|
||||
(inputs.xdph.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland.override {
|
||||
hyprland-share-picker = inputs.xdph.packages.${pkgs.stdenv.hostPlatform.system}.hyprland-share-picker.override {
|
||||
|
|
Loading…
Reference in a new issue