···2020 essential utilities. Now you can start <package>sway</package> from the TTY
2121 console.
2222 </para>
2323+2424+ <para>
2525+ If you are using a wlroots-based compositor, like sway, and want to be able to
2626+ share your screen, you might want to activate this option:
2727+<programlisting>
2828+<xref linkend="opt-xdg.portal.wlr.enable"/> = true;
2929+</programlisting>
3030+ and configure Pipewire using <xref linkend="opt-services.pipewire.enable"/>
3131+ and related options.
3232+ </para>
2333</chapter>
+67
nixos/modules/config/xdg/portals/wlr.nix
···11+{ config, pkgs, lib, ... }:
22+33+with lib;
44+55+let
66+ cfg = config.xdg.portal.wlr;
77+ package = pkgs.xdg-desktop-portal-wlr;
88+ settingsFormat = pkgs.formats.ini { };
99+ configFile = settingsFormat.generate "xdg-desktop-portal-wlr.ini" cfg.settings;
1010+in
1111+{
1212+ meta = {
1313+ maintainers = with maintainers; [ minijackson ];
1414+ };
1515+1616+ options.xdg.portal.wlr = {
1717+ enable = mkEnableOption ''
1818+ desktop portal for wlroots-based desktops
1919+2020+ This will add the <package>xdg-desktop-portal-wlr</package> package into
2121+ the <option>xdg.portal.extraPortals</option> option, and provide the
2222+ configuration file
2323+ '';
2424+2525+ settings = mkOption {
2626+ description = ''
2727+ Configuration for <package>xdg-desktop-portal-wlr</package>.
2828+2929+ See <literal>xdg-desktop-portal-wlr(5)</literal> for supported
3030+ values.
3131+ '';
3232+3333+ type = types.submodule {
3434+ freeformType = settingsFormat.type;
3535+ };
3636+3737+ default = { };
3838+3939+ # Example taken from the manpage
4040+ example = literalExample ''
4141+ {
4242+ screencast = {
4343+ output_name = "HDMI-A-1";
4444+ max_fps = 30;
4545+ exec_before = "disable_notifications.sh";
4646+ exec_after = "enable_notifications.sh";
4747+ chooser_type = "simple";
4848+ chooser_cmd = "''${pkgs.slurp}/bin/slurp -f %o -or";
4949+ };
5050+ }
5151+ '';
5252+ };
5353+ };
5454+5555+ config = mkIf cfg.enable {
5656+ xdg.portal = {
5757+ enable = true;
5858+ extraPortals = [ package ];
5959+ };
6060+6161+ systemd.user.services.xdg-desktop-portal-wlr.serviceConfig.ExecStart = [
6262+ # Empty ExecStart value to override the field
6363+ ""
6464+ "${package}/libexec/xdg-desktop-portal-wlr --config=${configFile}"
6565+ ];
6666+ };
6767+}