2021-02-05 17:12:51 +00:00
|
|
|
{ lib
|
|
|
|
, sway-unwrapped
|
2020-04-24 23:36:52 +00:00
|
|
|
, makeWrapper, symlinkJoin, writeShellScriptBin
|
|
|
|
, withBaseWrapper ? true, extraSessionCommands ? "", dbus
|
2020-05-15 21:57:56 +00:00
|
|
|
, withGtkWrapper ? false, wrapGAppsHook, gdk-pixbuf, glib, gtk3
|
2020-04-24 23:36:52 +00:00
|
|
|
, extraOptions ? [] # E.g.: [ "--verbose" ]
|
2021-05-20 23:08:51 +00:00
|
|
|
# Used by the NixOS module:
|
|
|
|
, isNixOS ? false
|
2021-10-17 09:34:42 +00:00
|
|
|
|
|
|
|
, enableXWayland ? true
|
2022-03-10 19:12:11 +00:00
|
|
|
, dbusSupport ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert extraSessionCommands != "" -> withBaseWrapper;
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2021-10-17 09:34:42 +00:00
|
|
|
sway = sway-unwrapped.override { inherit isNixOS enableXWayland; };
|
2020-04-24 23:36:52 +00:00
|
|
|
baseWrapper = writeShellScriptBin "sway" ''
|
|
|
|
set -o errexit
|
|
|
|
if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
|
2021-05-20 23:08:51 +00:00
|
|
|
export XDG_CURRENT_DESKTOP=sway
|
2020-04-24 23:36:52 +00:00
|
|
|
${extraSessionCommands}
|
|
|
|
export _SWAY_WRAPPER_ALREADY_EXECUTED=1
|
|
|
|
fi
|
|
|
|
if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
|
|
|
|
export DBUS_SESSION_BUS_ADDRESS
|
2021-05-20 23:08:51 +00:00
|
|
|
exec ${sway}/bin/sway "$@"
|
2020-04-24 23:36:52 +00:00
|
|
|
else
|
2022-03-10 19:12:11 +00:00
|
|
|
exec ${if !dbusSupport then "" else "${dbus}/bin/dbus-run-session"} ${sway}/bin/sway "$@"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in symlinkJoin {
|
2021-05-20 23:08:51 +00:00
|
|
|
name = "sway-${sway.version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
paths = (optional withBaseWrapper baseWrapper)
|
2021-05-20 23:08:51 +00:00
|
|
|
++ [ sway ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ]
|
|
|
|
++ (optional withGtkWrapper wrapGAppsHook);
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
buildInputs = optionals withGtkWrapper [ gdk-pixbuf glib gtk3 ];
|
|
|
|
|
|
|
|
# We want to run wrapProgram manually
|
|
|
|
dontWrapGApps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postBuild = ''
|
2020-05-15 21:57:56 +00:00
|
|
|
${optionalString withGtkWrapper "gappsWrapperArgsHook"}
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
wrapProgram $out/bin/sway \
|
|
|
|
${optionalString withGtkWrapper ''"''${gappsWrapperArgs[@]}"''} \
|
|
|
|
${optionalString (extraOptions != []) "${concatMapStrings (x: " --add-flags " + x) extraOptions}"}
|
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
passthru = {
|
|
|
|
inherit (sway.passthru) tests;
|
|
|
|
providedSessions = [ "sway" ];
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
inherit (sway) meta;
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|