Commit cf159c43 authored by Maëlys Bras de fer's avatar Maëlys Bras de fer
Browse files

nixos/{sway,river}: make XWayland support optional

parent a39290df
Loading
Loading
Loading
Loading
+23 −18
Original line number Diff line number Diff line
{
  config,
  pkgs,
  lib,
  ...
}:
{ config, lib, pkgs, ... }:

let
  cfg = config.programs.river;
in {
in
{
  options.programs.river = {
    enable = lib.mkEnableOption "river, a dynamic tiling Wayland compositor";

    package = lib.mkPackageOption pkgs "river" {
      nullable = true;
      default = pkgs.river.override {
        xwaylandSupport = cfg.xwayland.enable;
      };
      extraDescription = ''
        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.
      '';
    };

    xwayland.enable = lib.mkEnableOption "XWayland" // { default = true; };

    extraPackages = lib.mkOption {
      type = with lib.types; listOf package;
      default = with pkgs; [
@@ -41,8 +43,7 @@ in {
    };
  };

  config =
    lib.mkIf cfg.enable (lib.mkMerge [
  config = lib.mkIf cfg.enable (lib.mkMerge [
    {
      environment.systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;

@@ -52,7 +53,11 @@ in {
      # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
      xdg.portal.config.river.default = lib.mkDefault [ "wlr" "gtk" ];
    }
      (import ./wayland-session.nix { inherit lib pkgs; })

    (import ./wayland-session.nix {
      inherit lib pkgs;
      xwayland = cfg.xwayland.enable;
    })
  ]);

  meta.maintainers = with lib.maintainers; [ GaetanLepage ];
+50 −38
Original line number Diff line number Diff line
{ config, pkgs, lib, ... }:
{ config, lib, pkgs, ... }:

let
  cfg = config.programs.sway;
@@ -31,6 +31,7 @@ let
        "extraOptions"
        "withBaseWrapper"
        "withGtkWrapper"
        "enableXWayland"
        "isNixOS"
      ];
      existedArgs = with lib;
@@ -44,9 +45,11 @@ let
        extraOptions = cfg.extraOptions;
        withBaseWrapper = cfg.wrapperFeatures.base;
        withGtkWrapper = cfg.wrapperFeatures.gtk;
        enableXWayland = cfg.xwayland.enable;
        isNixOS = true;
      };
in {
in
{
  options.programs.sway = {
    enable = lib.mkEnableOption ''
      Sway, the i3-compatible tiling Wayland compositor. You can manually launch
@@ -63,8 +66,10 @@ in {
      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.
        `enableXWayland` and `isNixOS`, then the module options {option}`wrapperFeatures`,
        {option}`extraSessionCommands`, {option}`extraOptions` and {option}`wayland`
        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.
      '';
@@ -114,6 +119,8 @@ in {
      '';
    };

    xwayland.enable = lib.mkEnableOption "XWayland" // { default = true; };

    extraPackages = lib.mkOption {
      type = with lib.types; listOf package;
      default = with pkgs; [
@@ -135,11 +142,9 @@ in {
        for a list of useful software.
      '';
    };

  };

  config = lib.mkIf cfg.enable
    (lib.mkMerge [
  config = lib.mkIf cfg.enable (lib.mkMerge [
    {
      assertions = [
        {
@@ -153,8 +158,10 @@ in {

      environment = {
        systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;

        # Needed for the default wallpaper:
        pathsToLink = lib.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
@@ -168,12 +175,17 @@ in {

      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.optionals (cfg.package != null) [ cfg.package ];

      # 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 = lib.optionals (cfg.package != null) [ cfg.package ]; }
      (import ./wayland-session.nix { inherit lib pkgs; })
    (import ./wayland-session.nix {
      inherit lib pkgs;
      xwayland = cfg.xwayland.enable;
    })
  ]);

  meta.maintainers = with lib.maintainers; [ primeos colemickens ];
+20 −18
Original line number Diff line number Diff line
{ lib, pkgs, ... }: {
{ lib, pkgs, xwayland ? true }:

{
  security = {
    polkit.enable = true;
    pam.services.swaylock = {};
@@ -9,7 +11,7 @@

  programs = {
    dconf.enable = lib.mkDefault true;
      xwayland.enable = lib.mkDefault true;
    xwayland.enable = lib.mkDefault xwayland;
  };

  xdg.portal = {