summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Fufezan <fufexan@protonmail.com>2023-04-05 15:06:30 +0300
committerMihai Fufezan <fufexan@pm.me>2023-04-10 15:51:01 +0300
commit16d05a5c8bf06c1e945f90c8bae4131dea54c290 (patch)
tree0969170d0d43af018833f9710c085b319a390703
parent7faead75bd57b5d52572a6a46c9c38336b282fda (diff)
nix/*module: use mdDoc for documentation
Simplify and add more info to the docs.
-rw-r--r--nix/default.nix6
-rw-r--r--nix/hm-module.nix155
-rw-r--r--nix/module.nix101
3 files changed, 124 insertions, 138 deletions
diff --git a/nix/default.nix b/nix/default.nix
index 9924dbb3..e4c3e201 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -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"];
diff --git a/nix/hm-module.nix b/nix/hm-module.nix
index 9bad3fac..577bf5ca 100644
--- a/nix/hm-module.nix
+++ b/nix/hm-module.nix
@@ -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.
- '';
- };
-
- xwayland = {
- enable = lib.mkOption {
- type = lib.types.bool;
- default = true;
- description = ''
- Enable XWayland.
+ disableAutoreload =
+ lib.mkEnableOption null
+ // {
+ description = lib.mdDoc ''
+ Whether to disable automatically reloading Hyprland's configuration when
+ rebuilding the Home Manager profile.
'';
};
- hidpi = lib.mkOption {
- type = lib.types.bool;
- default = false;
- description = ''
- Enable HiDPI XWayland.
- '';
- };
- };
- nvidiaPatches = lib.mkOption {
- type = lib.types.bool;
- default = false;
- defaultText = lib.literalExpression "false";
- example = lib.literalExpression "true";
- description = ''
- Patch wlroots for better Nvidia support.
- '';
+ 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.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.
- '';
- };
-
- 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.
+ description = lib.mdDoc ''
+ Extra configuration lines to add to {file}`~/.config/hypr/hyprland.conf`.
'';
};
- 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"];
- };
- };
};
}
diff --git a/nix/module.nix b/nix/module.nix
index f96dd9e0..1423c9b5 100644
--- a/nix/module.nix
+++ b/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.
- package = mkOption {
- type = types.nullOr types.package;
- default = defaultHyprlandPackage;
- defaultText = literalExpression "<Hyprland flake>.packages.<system>.default";
- example = literalExpression "<Hyprland flake>.packages.<system>.default.override { }";
- description = ''
- Hyprland package to use.
- '';
- };
+ You can manually launch Hyprland by executing {command}`Hyprland` on a TTY.
- xwayland = {
- enable = mkOption {
- type = types.bool;
- default = true;
- description = ''
- Enable XWayland.
+ A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
+ See <https://wiki.hyprland.org> for more information.
'';
};
- hidpi = mkOption {
- type = types.bool;
- default = false;
- description = ''
- Enable HiDPI XWayland.
- '';
- };
- };
- nvidiaPatches = mkOption {
- type = types.bool;
- default = false;
- example = literalExpression "true";
- description = ''
- Patch wlroots for better Nvidia support.
+ package = mkOption {
+ type = types.path;
+ default = defaultHyprlandPackage;
+ 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.
'';
};
- recommendedEnvironment = mkOption {
- type = types.bool;
- default = true;
- defaultText = literalExpression "true";
- example = literalExpression "false";
- description = ''
- Whether to set the recommended environment variables.
- '';
+ 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 = 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 {