summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/wayland
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/programs/wayland')
-rw-r--r--nixos/modules/programs/wayland/hyprland.nix115
-rw-r--r--nixos/modules/programs/wayland/hyprlock.nix25
-rw-r--r--nixos/modules/programs/wayland/lib.nix12
-rw-r--r--nixos/modules/programs/wayland/river.nix72
-rw-r--r--nixos/modules/programs/wayland/sway.nix198
-rw-r--r--nixos/modules/programs/wayland/waybar.nix10
-rw-r--r--nixos/modules/programs/wayland/wayland-session.nix40
7 files changed, 239 insertions, 233 deletions
diff --git a/nixos/modules/programs/wayland/hyprland.nix b/nixos/modules/programs/wayland/hyprland.nix
index 5891ff25e437..98779ea7d03a 100644
--- a/nixos/modules/programs/wayland/hyprland.nix
+++ b/nixos/modules/programs/wayland/hyprland.nix
@@ -1,48 +1,43 @@
-{ config
-, lib
-, pkgs
-, ...
-}:
-with lib; let
+{ config, lib, pkgs, ... }:
+
+let
cfg = config.programs.hyprland;
- finalPortalPackage = cfg.portalPackage.override {
- hyprland = cfg.finalPackage;
- };
+ wayland-lib = import ./lib.nix { inherit lib; };
in
{
options.programs.hyprland = {
- enable = mkEnableOption null // {
- description = ''
- 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.
-
- A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
- See <https://wiki.hyprland.org> for more information.
+ enable = lib.mkEnableOption ''
+ 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 = lib.mkPackageOption pkgs "hyprland" {
+ extraDescription = ''
+ If the package is not overridable with `enableXWayland`, then the module option
+ {option}`xwayland` will have no effect.
'';
- };
-
- package = mkPackageOption pkgs "hyprland" { };
-
- finalPackage = mkOption {
- type = types.package;
- readOnly = true;
- default = cfg.package.override {
+ } // {
+ apply = p: wayland-lib.genFinalPackage p {
enableXWayland = cfg.xwayland.enable;
};
- defaultText = literalExpression
- "`programs.hyprland.package` with applied configuration";
- description = ''
- The Hyprland package after applying configuration.
- '';
};
- portalPackage = mkPackageOption pkgs "xdg-desktop-portal-hyprland" { };
+ portalPackage = lib.mkPackageOption pkgs "xdg-desktop-portal-hyprland" {
+ extraDescription = ''
+ If the package is not overridable with `hyprland`, then the Hyprland package
+ used by the portal may differ from the one set in the module option {option}`package`.
+ '';
+ } // {
+ apply = p: wayland-lib.genFinalPackage p {
+ hyprland = cfg.package;
+ };
+ };
- xwayland.enable = mkEnableOption ("XWayland") // { default = true; };
+ xwayland.enable = lib.mkEnableOption "XWayland" // { default = true; };
- systemd.setPath.enable = mkEnableOption null // {
+ systemd.setPath.enable = lib.mkEnableOption null // {
default = true;
example = false;
description = ''
@@ -53,46 +48,46 @@ in
};
};
- config = mkIf cfg.enable {
- environment.systemPackages = [ cfg.finalPackage ];
-
- fonts.enableDefaultPackages = mkDefault true;
- hardware.opengl.enable = mkDefault true;
-
- programs = {
- dconf.enable = mkDefault true;
- xwayland.enable = mkDefault cfg.xwayland.enable;
- };
+ config = lib.mkIf cfg.enable (lib.mkMerge [
+ {
+ environment.systemPackages = [ cfg.package ];
- security.polkit.enable = true;
+ # To make a Hyprland session available if a display manager like SDDM is enabled:
+ services.displayManager.sessionPackages = [ cfg.package ];
- services.displayManager.sessionPackages = [ cfg.finalPackage ];
+ xdg.portal = {
+ extraPortals = [ cfg.portalPackage ];
+ configPackages = lib.mkDefault [ cfg.package ];
+ };
- xdg.portal = {
- enable = mkDefault true;
- extraPortals = [ finalPortalPackage ];
- configPackages = mkDefault [ cfg.finalPackage ];
- };
+ systemd = lib.mkIf cfg.systemd.setPath.enable {
+ user.extraConfig = ''
+ DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin"
+ '';
+ };
+ }
- systemd = mkIf cfg.systemd.setPath.enable {
- user.extraConfig = ''
- DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin"
- '';
- };
- };
+ (import ./wayland-session.nix {
+ inherit lib pkgs;
+ enableXWayland = cfg.xwayland.enable;
+ enableWlrPortal = false; # Hyprland has its own portal, wlr is not needed
+ })
+ ]);
- imports = with lib; [
- (mkRemovedOptionModule
+ imports = [
+ (lib.mkRemovedOptionModule
[ "programs" "hyprland" "xwayland" "hidpi" ]
"XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
)
- (mkRemovedOptionModule
+ (lib.mkRemovedOptionModule
[ "programs" "hyprland" "enableNvidiaPatches" ]
"Nvidia patches are no longer needed"
)
- (mkRemovedOptionModule
+ (lib.mkRemovedOptionModule
[ "programs" "hyprland" "nvidiaPatches" ]
"Nvidia patches are no longer needed"
)
];
+
+ meta.maintainers = with lib.maintainers; [ fufexan ];
}
diff --git a/nixos/modules/programs/wayland/hyprlock.nix b/nixos/modules/programs/wayland/hyprlock.nix
new file mode 100644
index 000000000000..6c60765e80cc
--- /dev/null
+++ b/nixos/modules/programs/wayland/hyprlock.nix
@@ -0,0 +1,25 @@
+{ lib, pkgs, config, ... }:
+
+let
+ cfg = config.programs.hyprlock;
+in
+{
+ options.programs.hyprlock = {
+ enable = lib.mkEnableOption "hyprlock, Hyprland's GPU-accelerated screen locking utility";
+ package = lib.mkPackageOption pkgs "hyprlock" { };
+ };
+
+ config = lib.mkIf cfg.enable {
+ environment.systemPackages = [
+ cfg.package
+ ];
+
+ # Hyprlock needs Hypridle systemd service to be running to detect idle time
+ services.hypridle.enable = true;
+
+ # Hyprlock needs PAM access to authenticate, else it fallbacks to su
+ security.pam.services.hyprlock = {};
+ };
+
+ meta.maintainers = with lib.maintainers; [ johnrtitor ];
+}
diff --git a/nixos/modules/programs/wayland/lib.nix b/nixos/modules/programs/wayland/lib.nix
new file mode 100644
index 000000000000..0f275d3f18c5
--- /dev/null
+++ b/nixos/modules/programs/wayland/lib.nix
@@ -0,0 +1,12 @@
+{ lib }:
+
+{
+ genFinalPackage = pkg: args:
+ let
+ expectedArgs = with lib;
+ lib.naturalSort (lib.attrNames args);
+ existingArgs = with lib;
+ naturalSort (intersectLists expectedArgs (attrNames (functionArgs pkg.override)));
+ in
+ if existingArgs != expectedArgs then pkg else pkg.override args;
+}
diff --git a/nixos/modules/programs/wayland/river.nix b/nixos/modules/programs/wayland/river.nix
index d0e309646b0e..6391f00e2f62 100644
--- a/nixos/modules/programs/wayland/river.nix
+++ b/nixos/modules/programs/wayland/river.nix
@@ -1,37 +1,40 @@
-{
- config,
- pkgs,
- lib,
- ...
-}:
-with lib; let
+{ config, lib, pkgs, ... }:
+
+let
cfg = config.programs.river;
-in {
+
+ wayland-lib = import ./lib.nix { inherit lib; };
+in
+{
options.programs.river = {
- enable = mkEnableOption "river, a dynamic tiling Wayland compositor";
+ enable = lib.mkEnableOption "river, a dynamic tiling Wayland compositor";
- package = mkPackageOption pkgs "river" {
+ package = lib.mkPackageOption pkgs "river" {
nullable = true;
extraDescription = ''
+ If the package is not overridable with `xwaylandSupport`, then the module option
+ {option}`xwayland` will have no effect.
+
Set to `null` to not add any River package to your path.
This should be done if you want to use the Home Manager River module to install River.
'';
+ } // {
+ apply = p: if p == null then null else
+ wayland-lib.genFinalPackage p {
+ xwaylandSupport = cfg.xwayland.enable;
+ };
};
- extraPackages = mkOption {
- type = with types; listOf package;
- default = with pkgs; [
- swaylock
- foot
- dmenu
- ];
- defaultText = literalExpression ''
+ xwayland.enable = lib.mkEnableOption "XWayland" // { default = true; };
+
+ extraPackages = lib.mkOption {
+ type = with lib.types; listOf package;
+ default = with pkgs; [ swaylock foot dmenu ];
+ defaultText = lib.literalExpression ''
with pkgs; [ swaylock foot dmenu ];
'';
- example = literalExpression ''
- with pkgs; [
- termite rofi light
- ]
+ example = lib.literalExpression ''
+ with pkgs; [ termite rofi light ]
'';
description = ''
Extra packages to be installed system wide. See
@@ -41,19 +44,22 @@ in {
};
};
- config =
- mkIf cfg.enable (mkMerge [
- {
- environment.systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
+ config = lib.mkIf cfg.enable (lib.mkMerge [
+ {
+ environment.systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
+
+ # To make a river session available if a display manager like SDDM is enabled:
+ services.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
- # To make a river session available if a display manager like SDDM is enabled:
- services.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ];
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
+ xdg.portal.config.river.default = lib.mkDefault [ "wlr" "gtk" ];
+ }
- # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
- xdg.portal.config.river.default = mkDefault [ "wlr" "gtk" ];
- }
- (import ./wayland-session.nix { inherit lib pkgs; })
- ]);
+ (import ./wayland-session.nix {
+ inherit lib pkgs;
+ enableXWayland = cfg.xwayland.enable;
+ })
+ ]);
meta.maintainers = with lib.maintainers; [ GaetanLepage ];
}
diff --git a/nixos/modules/programs/wayland/sway.nix b/nixos/modules/programs/wayland/sway.nix
index 348e1db7cdc1..e3e32aa7a56a 100644
--- a/nixos/modules/programs/wayland/sway.nix
+++ b/nixos/modules/programs/wayland/sway.nix
@@ -1,88 +1,53 @@
-{ config, pkgs, lib, ... }:
-
-with lib;
+{ config, lib, pkgs, ... }:
let
cfg = config.programs.sway;
- wrapperOptions = types.submodule {
- options =
- let
- mkWrapperFeature = default: description: mkOption {
- type = types.bool;
- inherit default;
- example = !default;
- description = "Whether to make use of the ${description}";
- };
- in {
- base = mkWrapperFeature true ''
- base wrapper to execute extra session commands and prepend a
- dbus-run-session to the sway command.
- '';
- gtk = mkWrapperFeature false ''
- wrapGAppsHook wrapper to execute sway with required environment
- variables for GTK applications.
- '';
- };
- };
-
- genFinalPackage = pkg:
- let
- expectedArgs = lib.naturalSort [
- "extraSessionCommands"
- "extraOptions"
- "withBaseWrapper"
- "withGtkWrapper"
- "isNixOS"
- ];
- existedArgs = with lib;
- naturalSort
- (intersectLists expectedArgs (attrNames (functionArgs pkg.override)));
- in if existedArgs != expectedArgs then
- pkg
- else
- pkg.override {
- extraSessionCommands = cfg.extraSessionCommands;
- extraOptions = cfg.extraOptions;
- withBaseWrapper = cfg.wrapperFeatures.base;
- withGtkWrapper = cfg.wrapperFeatures.gtk;
- isNixOS = true;
- };
-in {
+ wayland-lib = import ./lib.nix { inherit lib; };
+in
+{
options.programs.sway = {
- enable = mkEnableOption ''
+ enable = lib.mkEnableOption ''
Sway, the i3-compatible tiling Wayland compositor. You can manually launch
Sway by executing "exec sway" on a TTY. Copy /etc/sway/config to
~/.config/sway/config to modify the default configuration. See
<https://github.com/swaywm/sway/wiki> and
"man 5 sway" for more information'';
- package = mkOption {
- type = with types; nullOr package;
- default = pkgs.sway;
- apply = p: if p == null then null else genFinalPackage p;
- defaultText = literalExpression "pkgs.sway";
- description = ''
- Sway package to use. If the package does not contain the override arguments
- `extraSessionCommands`, `extraOptions`, `withBaseWrapper`, `withGtkWrapper`,
- `isNixOS`, then the module options {option}`wrapperFeatures`,
- {option}`wrapperFeatures` and {option}`wrapperFeatures` will have no effect.
- Set to `null` to not add any Sway package to your path. This should be done if
- you want to use the Home Manager Sway module to install Sway.
+ package = lib.mkPackageOption pkgs "sway" {
+ nullable = true;
+ extraDescription = ''
+ If the package is not overridable with `extraSessionCommands`, `extraOptions`,
+ `withBaseWrapper`, `withGtkWrapper`, `enableXWayland` and `isNixOS`,
+ then the module options {option}`wrapperFeatures`, {option}`extraSessionCommands`,
+ {option}`extraOptions` and {option}`xwayland` will have no effect.
+
+ Set to `null` to not add any Sway package to your path.
+ This should be done if you want to use the Home Manager Sway module to install Sway.
'';
+ } // {
+ apply = p: if p == null then null else
+ wayland-lib.genFinalPackage p {
+ extraSessionCommands = cfg.extraSessionCommands;
+ extraOptions = cfg.extraOptions;
+ withBaseWrapper = cfg.wrapperFeatures.base;
+ withGtkWrapper = cfg.wrapperFeatures.gtk;
+ enableXWayland = cfg.xwayland.enable;
+ isNixOS = true;
+ };
};
- wrapperFeatures = mkOption {
- type = wrapperOptions;
- default = { };
- example = { gtk = true; };
- description = ''
- Attribute set of features to enable in the wrapper.
- '';
+ wrapperFeatures = {
+ base = lib.mkEnableOption ''
+ the base wrapper to execute extra session commands and prepend a
+ dbus-run-session to the sway command'' // { default = true; };
+ gtk = lib.mkEnableOption ''
+ the wrapGAppsHook wrapper to execute sway with required environment
+ variables for GTK applications'';
};
- extraSessionCommands = mkOption {
- type = types.lines;
+ extraSessionCommands = lib.mkOption {
+ type = lib.types.lines;
default = "";
example = ''
# SDL:
@@ -102,8 +67,8 @@ in {
'';
};
- extraOptions = mkOption {
- type = types.listOf types.str;
+ extraOptions = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
default = [];
example = [
"--verbose"
@@ -116,19 +81,16 @@ in {
'';
};
- extraPackages = mkOption {
- type = with types; listOf package;
- default = with pkgs; [
- swaylock swayidle foot dmenu wmenu
- ];
- defaultText = literalExpression ''
+ xwayland.enable = lib.mkEnableOption "XWayland" // { default = true; };
+
+ extraPackages = lib.mkOption {
+ type = with lib.types; listOf package;
+ default = with pkgs; [ swaylock swayidle foot dmenu wmenu ];
+ defaultText = lib.literalExpression ''
with pkgs; [ swaylock swayidle foot dmenu wmenu ];
'';
- example = literalExpression ''
- with pkgs; [
- i3status i3status-rust
- termite rofi light
- ]
+ example = lib.literalExpression ''
+ with pkgs; [ i3status i3status-rust termite rofi light ]
'';
description = ''
Extra packages to be installed system wide. See
@@ -137,46 +99,50 @@ in {
for a list of useful software.
'';
};
-
};
- config = mkIf cfg.enable
- (mkMerge [
- {
- assertions = [
- {
- assertion = cfg.extraSessionCommands != "" -> cfg.wrapperFeatures.base;
- message = ''
- The extraSessionCommands for Sway will not be run if
- wrapperFeatures.base is disabled.
- '';
- }
- ];
-
- environment = {
- systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
- # Needed for the default wallpaper:
- pathsToLink = optionals (cfg.package != null) [ "/share/backgrounds/sway" ];
- etc = {
- "sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" ''
- # Import the most important environment variables into the D-Bus and systemd
- # user environments (e.g. required for screen sharing and Pinentry prompts):
- exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
- '';
- } // optionalAttrs (cfg.package != null) {
- "sway/config".source = mkOptionDefault "${cfg.package}/etc/sway/config";
- };
+ config = lib.mkIf cfg.enable (lib.mkMerge [
+ {
+ assertions = [
+ {
+ assertion = cfg.extraSessionCommands != "" -> cfg.wrapperFeatures.base;
+ message = ''
+ The extraSessionCommands for Sway will not be run if wrapperFeatures.base is disabled.
+ '';
+ }
+ ];
+
+ environment = {
+ systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
+
+ # Needed for the default wallpaper:
+ pathsToLink = lib.optional (cfg.package != null) "/share/backgrounds/sway";
+
+ etc = {
+ "sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" ''
+ # Import the most important environment variables into the D-Bus and systemd
+ # user environments (e.g. required for screen sharing and Pinentry prompts):
+ exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
+ '';
+ } // lib.optionalAttrs (cfg.package != null) {
+ "sway/config".source = lib.mkOptionDefault "${cfg.package}/etc/sway/config";
};
+ };
+
+ programs.gnupg.agent.pinentryPackage = lib.mkDefault pkgs.pinentry-gnome3;
- programs.gnupg.agent.pinentryPackage = lib.mkDefault pkgs.pinentry-gnome3;
+ # To make a Sway session available if a display manager like SDDM is enabled:
+ services.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
- # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
- xdg.portal.config.sway.default = mkDefault [ "wlr" "gtk" ];
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
+ xdg.portal.config.sway.default = lib.mkDefault [ "wlr" "gtk" ];
+ }
- # To make a Sway session available if a display manager like SDDM is enabled:
- services.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ]; }
- (import ./wayland-session.nix { inherit lib pkgs; })
- ]);
+ (import ./wayland-session.nix {
+ inherit lib pkgs;
+ enableXWayland = cfg.xwayland.enable;
+ })
+ ]);
meta.maintainers = with lib.maintainers; [ primeos colemickens ];
}
diff --git a/nixos/modules/programs/wayland/waybar.nix b/nixos/modules/programs/wayland/waybar.nix
index ffe889504cd3..ab811994be07 100644
--- a/nixos/modules/programs/wayland/waybar.nix
+++ b/nixos/modules/programs/wayland/waybar.nix
@@ -1,17 +1,15 @@
{ lib, pkgs, config, ... }:
-with lib;
-
let
cfg = config.programs.waybar;
in
{
options.programs.waybar = {
- enable = mkEnableOption "waybar, a highly customizable Wayland bar for Sway and Wlroots based compositors";
- package = mkPackageOption pkgs "waybar" { };
+ enable = lib.mkEnableOption "waybar, a highly customizable Wayland bar for Sway and Wlroots based compositors";
+ package = lib.mkPackageOption pkgs "waybar" { };
};
- config = mkIf cfg.enable {
+ config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
systemd.user.services.waybar = {
description = "Waybar as systemd service";
@@ -21,5 +19,5 @@ in
};
};
- meta.maintainers = [ maintainers.FlorianFranzen ];
+ meta.maintainers = [ lib.maintainers.FlorianFranzen ];
}
diff --git a/nixos/modules/programs/wayland/wayland-session.nix b/nixos/modules/programs/wayland/wayland-session.nix
index da117ceae0ad..877b10668470 100644
--- a/nixos/modules/programs/wayland/wayland-session.nix
+++ b/nixos/modules/programs/wayland/wayland-session.nix
@@ -1,23 +1,27 @@
-{ lib, pkgs, ... }: with lib; {
- security = {
- polkit.enable = true;
- pam.services.swaylock = {};
- };
+{
+ lib,
+ pkgs,
+ enableXWayland ? true,
+ enableWlrPortal ? true,
+}:
- hardware.opengl.enable = mkDefault true;
- fonts.enableDefaultPackages = mkDefault true;
+{
+ security = {
+ polkit.enable = true;
+ pam.services.swaylock = {};
+ };
- programs = {
- dconf.enable = mkDefault true;
- xwayland.enable = mkDefault true;
- };
+ hardware.opengl.enable = lib.mkDefault true;
+ fonts.enableDefaultPackages = lib.mkDefault true;
- xdg.portal = {
- enable = mkDefault true;
+ programs = {
+ dconf.enable = lib.mkDefault true;
+ xwayland.enable = lib.mkDefault enableXWayland;
+ };
- extraPortals = [
- # For screen sharing
- pkgs.xdg-desktop-portal-wlr
- ];
- };
+ xdg.portal.wlr.enable = enableWlrPortal;
+
+ # Window manager only sessions (unlike DEs) don't handle XDG
+ # autostart files, so force them to run the service
+ services.xserver.desktopManager.runXdgAutostartIfNone = lib.mkDefault true;
}