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