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
|
2023-07-15 17:15:38 +00:00
|
|
|
sway = sway-unwrapped.overrideAttrs (oa: { inherit isNixOS enableXWayland; });
|
2024-01-02 11:29:13 +00:00
|
|
|
baseWrapper = writeShellScriptBin sway.meta.mainProgram ''
|
2020-04-24 23:36:52 +00:00
|
|
|
set -o errexit
|
|
|
|
if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
|
2024-01-02 11:29:13 +00:00
|
|
|
export XDG_CURRENT_DESKTOP=${sway.meta.mainProgram}
|
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
|
2024-01-02 11:29:13 +00:00
|
|
|
exec ${lib.getExe sway} "$@"
|
2020-04-24 23:36:52 +00:00
|
|
|
else
|
2024-01-02 11:29:13 +00:00
|
|
|
exec ${lib.optionalString dbusSupport "${dbus}/bin/dbus-run-session"} ${lib.getExe sway} "$@"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
'';
|
2024-01-02 11:29:13 +00:00
|
|
|
in symlinkJoin rec {
|
|
|
|
pname = lib.replaceStrings ["-unwrapped"] [""] sway.pname;
|
|
|
|
inherit (sway) version;
|
|
|
|
name = "${pname}-${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-06-16 17:23:12 +00:00
|
|
|
strictDeps = false;
|
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"}
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
wrapProgram $out/bin/${sway.meta.mainProgram} \
|
2020-04-24 23:36:52 +00:00
|
|
|
${optionalString withGtkWrapper ''"''${gappsWrapperArgs[@]}"''} \
|
|
|
|
${optionalString (extraOptions != []) "${concatMapStrings (x: " --add-flags " + x) extraOptions}"}
|
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
passthru = {
|
|
|
|
inherit (sway.passthru) tests;
|
2024-01-02 11:29:13 +00:00
|
|
|
providedSessions = [ sway.meta.mainProgram ];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
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
|
|
|
}
|