7 withBaseWrapper ? true,
8 extraSessionCommands ? "",
10 withGtkWrapper ? false,
15 extraOptions ? [ ], # E.g.: [ "--verbose" ]
16 # Used by the NixOS module:
19 enableXWayland ? true,
23 assert extraSessionCommands != "" -> withBaseWrapper;
26 inherit (builtins) replaceStrings;
27 inherit (lib.lists) optional optionals;
28 inherit (lib.meta) getExe;
29 inherit (lib.strings) concatMapStrings optionalString;
31 sway = sway-unwrapped.overrideAttrs (oa: {
32 inherit isNixOS enableXWayland;
34 baseWrapper = writeShellScriptBin sway.meta.mainProgram ''
36 if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
37 export XDG_CURRENT_DESKTOP=${sway.meta.mainProgram}
38 ${extraSessionCommands}
39 export _SWAY_WRAPPER_ALREADY_EXECUTED=1
41 if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
42 export DBUS_SESSION_BUS_ADDRESS
43 exec ${getExe sway} "$@"
45 exec ${optionalString dbusSupport "${dbus}/bin/dbus-run-session"} ${getExe sway} "$@"
50 pname = replaceStrings [ "-unwrapped" ] [ "" ] sway.pname;
51 inherit (sway) version;
52 name = "${pname}-${version}";
54 paths = (optional withBaseWrapper baseWrapper) ++ [ sway ];
57 nativeBuildInputs = [ makeWrapper ] ++ (optional withGtkWrapper wrapGAppsHook3);
59 buildInputs = optionals withGtkWrapper [
65 # We want to run wrapProgram manually
69 ${optionalString withGtkWrapper "gappsWrapperArgsHook"}
71 wrapProgram $out/bin/${sway.meta.mainProgram} \
72 ${optionalString withGtkWrapper ''"''${gappsWrapperArgs[@]}"''} \
73 ${optionalString (extraOptions != [ ])
74 "${concatMapStrings (x: " --add-flags " + x) extraOptions}"
79 inherit (sway.passthru) tests;
80 providedSessions = [ sway.meta.mainProgram ];