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.

85 lines
2.0 KiB
Nix
Raw Permalink Normal View History

{
lib,
sway-unwrapped,
2019-12-08 13:56:56 +01:00
makeWrapper,
symlinkJoin,
writeShellScriptBin,
withBaseWrapper ? true,
extraSessionCommands ? "",
dbus,
withGtkWrapper ? false,
wrapGAppsHook3,
gdk-pixbuf,
glib,
gtk3,
extraOptions ? [ ], # E.g.: [ "--verbose" ]
# Used by the NixOS module:
isNixOS ? false,
2021-10-11 21:41:06 +02:00
enableXWayland ? true,
dbusSupport ? true,
2019-12-08 13:56:56 +01:00
}:
assert extraSessionCommands != "" -> withBaseWrapper;
let
2024-03-28 09:18:49 -04:00
inherit (builtins) replaceStrings;
inherit (lib.lists) optional optionals;
inherit (lib.meta) getExe;
inherit (lib.strings) concatMapStrings optionalString;
sway = sway-unwrapped.overrideAttrs (oa: {
inherit isNixOS enableXWayland;
});
baseWrapper = writeShellScriptBin sway.meta.mainProgram ''
2019-12-08 13:56:56 +01:00
set -o errexit
if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
export XDG_CURRENT_DESKTOP=${sway.meta.mainProgram}
2019-12-08 13:56:56 +01:00
${extraSessionCommands}
export _SWAY_WRAPPER_ALREADY_EXECUTED=1
2019-12-08 13:56:56 +01:00
fi
if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
export DBUS_SESSION_BUS_ADDRESS
2024-03-28 09:18:49 -04:00
exec ${getExe sway} "$@"
2019-12-08 13:56:56 +01:00
else
2024-03-28 09:18:49 -04:00
exec ${optionalString dbusSupport "${dbus}/bin/dbus-run-session"} ${getExe sway} "$@"
2019-12-08 13:56:56 +01:00
fi
'';
2023-12-14 21:14:12 +01:00
in
symlinkJoin rec {
2024-03-28 09:18:49 -04:00
pname = replaceStrings [ "-unwrapped" ] [ "" ] sway.pname;
2023-12-14 21:14:12 +01:00
inherit (sway) version;
name = "${pname}-${version}";
2019-12-08 13:56:56 +01:00
paths = (optional withBaseWrapper baseWrapper) ++ [ sway ];
strictDeps = false;
nativeBuildInputs = [ makeWrapper ] ++ (optional withGtkWrapper wrapGAppsHook3);
2019-12-08 13:56:56 +01:00
buildInputs = optionals withGtkWrapper [
gdk-pixbuf
glib
gtk3
];
# We want to run wrapProgram manually
dontWrapGApps = true;
2019-12-08 13:56:56 +01: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 13:56:56 +01:00
'';
passthru = {
inherit (sway.passthru) tests;
providedSessions = [ sway.meta.mainProgram ];
};
2019-12-08 13:56:56 +01:00
inherit (sway) meta;
2019-12-08 13:56:56 +01:00
}