nixpkgs/pkgs/by-name/sw/sway/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.9 KiB
Nix
Raw Normal View History

{ lib
, sway-unwrapped
2019-12-08 12:56:56 +00:00
, makeWrapper, symlinkJoin, writeShellScriptBin
, withBaseWrapper ? true, extraSessionCommands ? "", dbus
, withGtkWrapper ? false, wrapGAppsHook, gdk-pixbuf, glib, gtk3
, extraOptions ? [] # E.g.: [ "--verbose" ]
# Used by the NixOS module:
, isNixOS ? false
2021-10-11 19:41:06 +00:00
, enableXWayland ? true
, dbusSupport ? true
2019-12-08 12:56:56 +00:00
}:
assert extraSessionCommands != "" -> withBaseWrapper;
with lib;
let
sway = sway-unwrapped.overrideAttrs (oa: { inherit isNixOS enableXWayland; });
baseWrapper = writeShellScriptBin sway.meta.mainProgram ''
2019-12-08 12:56:56 +00:00
set -o errexit
if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
export XDG_CURRENT_DESKTOP=${sway.meta.mainProgram}
2019-12-08 12:56:56 +00:00
${extraSessionCommands}
export _SWAY_WRAPPER_ALREADY_EXECUTED=1
2019-12-08 12:56:56 +00:00
fi
if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
export DBUS_SESSION_BUS_ADDRESS
exec ${lib.getExe sway} "$@"
2019-12-08 12:56:56 +00:00
else
exec ${lib.optionalString dbusSupport "${dbus}/bin/dbus-run-session"} ${lib.getExe sway} "$@"
2019-12-08 12:56:56 +00:00
fi
'';
2023-12-14 20:14:12 +00:00
in symlinkJoin rec {
pname = lib.replaceStrings ["-unwrapped"] [""] sway.pname;
inherit (sway) version;
name = "${pname}-${version}";
2019-12-08 12:56:56 +00:00
paths = (optional withBaseWrapper baseWrapper)
++ [ sway ];
2019-12-08 12:56:56 +00:00
strictDeps = false;
2019-12-08 12:56:56 +00:00
nativeBuildInputs = [ makeWrapper ]
++ (optional withGtkWrapper wrapGAppsHook);
buildInputs = optionals withGtkWrapper [ gdk-pixbuf glib gtk3 ];
# We want to run wrapProgram manually
dontWrapGApps = true;
2019-12-08 12:56:56 +00:00
postBuild = ''
${optionalString withGtkWrapper "gappsWrapperArgsHook"}
wrapProgram $out/bin/${sway.meta.mainProgram} \
${optionalString withGtkWrapper ''"''${gappsWrapperArgs[@]}"''} \
${optionalString (extraOptions != []) "${concatMapStrings (x: " --add-flags " + x) extraOptions}"}
2019-12-08 12:56:56 +00:00
'';
passthru = {
inherit (sway.passthru) tests;
providedSessions = [ sway.meta.mainProgram ];
};
2019-12-08 12:56:56 +00:00
inherit (sway) meta;
2019-12-08 12:56:56 +00:00
}