at master 1.7 kB view raw
1{ 2 config, 3 pkgs, 4 lib, 5 ... 6}: 7let 8 cfg = config.xdg.portal.wlr; 9 package = pkgs.xdg-desktop-portal-wlr; 10 settingsFormat = pkgs.formats.ini { }; 11 configFile = settingsFormat.generate "xdg-desktop-portal-wlr.ini" cfg.settings; 12in 13{ 14 meta = { 15 maintainers = with lib.maintainers; [ minijackson ]; 16 }; 17 18 options.xdg.portal.wlr = { 19 enable = lib.mkEnableOption '' 20 desktop portal for wlroots-based desktops. 21 22 This will add the `xdg-desktop-portal-wlr` package into 23 the {option}`xdg.portal.extraPortals` option, and provide the 24 configuration file 25 ''; 26 27 settings = lib.mkOption { 28 description = '' 29 Configuration for `xdg-desktop-portal-wlr`. 30 31 See {manpage}`xdg-desktop-portal-wlr(5)` for supported 32 values. 33 ''; 34 35 type = lib.types.submodule { 36 freeformType = settingsFormat.type; 37 }; 38 39 default = { }; 40 41 # Example taken from the manpage 42 example = lib.literalExpression '' 43 { 44 screencast = { 45 output_name = "HDMI-A-1"; 46 max_fps = 30; 47 exec_before = "disable_notifications.sh"; 48 exec_after = "enable_notifications.sh"; 49 chooser_type = "simple"; 50 chooser_cmd = "''${pkgs.slurp}/bin/slurp -f %o -or"; 51 }; 52 } 53 ''; 54 }; 55 }; 56 57 config = lib.mkIf cfg.enable { 58 xdg.portal = { 59 enable = true; 60 extraPortals = [ package ]; 61 }; 62 63 systemd.user.services.xdg-desktop-portal-wlr.serviceConfig.ExecStart = [ 64 # Empty ExecStart value to override the field 65 "" 66 "${package}/libexec/xdg-desktop-portal-wlr --config=${configFile}" 67 ]; 68 }; 69}