2022-05-11 20:00:24 +00:00
|
|
|
{ stdenv, lib, makeDesktopItem, makeWrapper, makeBinaryWrapper, lndir, config
|
2022-10-01 16:58:22 +00:00
|
|
|
, jq, xdg-utils, writeText
|
2016-01-10 09:35:45 +00:00
|
|
|
|
|
|
|
## various stuff that can be plugged in
|
2022-09-01 22:12:29 +00:00
|
|
|
, ffmpeg_5, xorg, alsa-lib, libpulseaudio, libcanberra-gtk3, libglvnd, libnotify, opensc
|
2021-05-07 21:18:14 +00:00
|
|
|
, gnome/*.gnome-shell*/
|
2022-07-26 22:23:44 +00:00
|
|
|
, browserpass, gnome-browser-connector, uget-integrator, plasma5Packages, bukubrow, pipewire
|
2019-05-28 11:14:06 +00:00
|
|
|
, tridactyl-native
|
2019-03-07 00:27:52 +00:00
|
|
|
, fx_cast_bridge
|
2018-07-17 20:11:16 +00:00
|
|
|
, udev
|
2021-03-14 16:11:48 +00:00
|
|
|
, libkrb5
|
2020-03-04 07:21:06 +00:00
|
|
|
, libva
|
2020-07-10 02:56:06 +00:00
|
|
|
, mesa # firefox wants gbm for drm+dmabuf
|
2021-06-09 15:09:59 +00:00
|
|
|
, cups
|
2022-03-21 20:58:03 +00:00
|
|
|
, pciutils
|
2022-05-07 22:31:10 +00:00
|
|
|
, sndio
|
|
|
|
, libjack2
|
2023-01-12 23:52:28 +00:00
|
|
|
, speechd
|
2016-01-10 09:35:45 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
## configurability of the wrapper itself
|
2017-11-16 15:39:16 +00:00
|
|
|
|
2016-04-01 11:51:24 +00:00
|
|
|
browser:
|
2004-10-17 13:28:28 +00:00
|
|
|
|
2016-01-10 09:35:45 +00:00
|
|
|
let
|
2017-11-16 15:39:16 +00:00
|
|
|
wrapper =
|
2022-03-21 15:03:59 +00:00
|
|
|
{ applicationName ? browser.binaryName or (lib.getName browser)
|
2021-07-13 17:04:57 +00:00
|
|
|
, pname ? applicationName
|
2019-11-24 17:27:45 +00:00
|
|
|
, version ? lib.getVersion browser
|
2021-07-13 17:04:57 +00:00
|
|
|
, desktopName ? # applicationName with first letter capitalized
|
|
|
|
(lib.toUpper (lib.substring 0 1 applicationName) + lib.substring 1 (-1) applicationName)
|
2017-11-16 15:39:16 +00:00
|
|
|
, nameSuffix ? ""
|
2021-07-13 17:04:57 +00:00
|
|
|
, icon ? applicationName
|
2023-02-27 19:54:16 +00:00
|
|
|
, wmClass ? applicationName
|
2017-11-16 15:39:36 +00:00
|
|
|
, extraNativeMessagingHosts ? []
|
2020-07-04 08:04:30 +00:00
|
|
|
, pkcs11Modules ? []
|
2020-07-07 06:21:23 +00:00
|
|
|
, useGlvnd ? true
|
2021-07-13 17:04:57 +00:00
|
|
|
, cfg ? config.${applicationName} or {}
|
2020-06-28 13:55:07 +00:00
|
|
|
|
|
|
|
## Following options are needed for extra prefs & policies
|
2020-11-30 15:30:46 +00:00
|
|
|
# For more information about anti tracking (german website)
|
2020-12-01 21:07:34 +00:00
|
|
|
# visit https://wiki.kairaven.de/open/app/firefox
|
2020-06-28 13:55:07 +00:00
|
|
|
, extraPrefs ? ""
|
2022-02-11 18:05:45 +00:00
|
|
|
, extraPrefsFiles ? []
|
2020-11-30 15:30:46 +00:00
|
|
|
# For more information about policies visit
|
|
|
|
# https://github.com/mozilla/policy-templates#enterprisepoliciesenabled
|
2020-06-28 13:55:07 +00:00
|
|
|
, extraPolicies ? {}
|
2022-02-11 18:05:45 +00:00
|
|
|
, extraPoliciesFiles ? []
|
2021-05-03 14:22:33 +00:00
|
|
|
, libName ? browser.libName or "firefox" # Important for tor package or the like
|
2020-12-04 16:53:14 +00:00
|
|
|
, nixExtensions ? null
|
2017-11-16 15:39:16 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
ffmpegSupport = browser.ffmpegSupport or false;
|
|
|
|
gssSupport = browser.gssSupport or false;
|
2020-10-22 01:47:30 +00:00
|
|
|
alsaSupport = browser.alsaSupport or false;
|
2020-12-10 02:26:58 +00:00
|
|
|
pipewireSupport = browser.pipewireSupport or false;
|
2022-05-07 22:31:10 +00:00
|
|
|
sndioSupport = browser.sndioSupport or false;
|
|
|
|
jackSupport = browser.jackSupport or false;
|
2021-08-05 14:50:45 +00:00
|
|
|
# PCSC-Lite daemon (services.pcscd) also must be enabled for firefox to access smartcards
|
|
|
|
smartcardSupport = cfg.smartcardSupport or false;
|
2017-11-16 15:39:16 +00:00
|
|
|
|
|
|
|
nativeMessagingHosts =
|
2023-02-27 19:54:16 +00:00
|
|
|
[ ]
|
2018-07-07 19:11:19 +00:00
|
|
|
++ lib.optional (cfg.enableBrowserpass or false) (lib.getBin browserpass)
|
2018-07-30 21:02:32 +00:00
|
|
|
++ lib.optional (cfg.enableBukubrow or false) bukubrow
|
2019-05-28 11:14:06 +00:00
|
|
|
++ lib.optional (cfg.enableTridactylNative or false) tridactyl-native
|
2022-07-26 22:23:44 +00:00
|
|
|
++ lib.optional (cfg.enableGnomeExtensions or false) gnome-browser-connector
|
2018-04-30 02:41:36 +00:00
|
|
|
++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator
|
2020-12-11 18:52:16 +00:00
|
|
|
++ lib.optional (cfg.enablePlasmaBrowserIntegration or false) plasma5Packages.plasma-browser-integration
|
2019-03-07 00:27:52 +00:00
|
|
|
++ lib.optional (cfg.enableFXCastBridge or false) fx_cast_bridge
|
2017-11-16 15:39:36 +00:00
|
|
|
++ extraNativeMessagingHosts
|
2023-02-27 19:54:16 +00:00
|
|
|
;
|
2022-03-21 20:58:03 +00:00
|
|
|
libs = lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups pciutils ]
|
2022-03-21 13:28:16 +00:00
|
|
|
++ lib.optional pipewireSupport pipewire
|
2022-09-01 22:12:29 +00:00
|
|
|
++ lib.optional ffmpegSupport ffmpeg_5
|
2021-03-14 16:11:48 +00:00
|
|
|
++ lib.optional gssSupport libkrb5
|
2020-07-07 06:21:23 +00:00
|
|
|
++ lib.optional useGlvnd libglvnd
|
2017-11-16 15:39:16 +00:00
|
|
|
++ lib.optionals (cfg.enableQuakeLive or false)
|
2021-06-10 02:57:09 +00:00
|
|
|
(with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsa-lib zlib ])
|
2020-07-04 08:04:30 +00:00
|
|
|
++ lib.optional (config.pulseaudio or true) libpulseaudio
|
2021-06-10 02:57:09 +00:00
|
|
|
++ lib.optional alsaSupport alsa-lib
|
2022-05-07 22:31:10 +00:00
|
|
|
++ lib.optional sndioSupport sndio
|
|
|
|
++ lib.optional jackSupport libjack2
|
2021-08-05 14:50:45 +00:00
|
|
|
++ lib.optional smartcardSupport opensc
|
2023-01-12 23:52:28 +00:00
|
|
|
++ lib.optional (cfg.speechSynthesisSupport or false) speechd
|
2020-07-04 08:04:30 +00:00
|
|
|
++ pkcs11Modules;
|
2021-07-12 13:56:03 +00:00
|
|
|
gtk_modules = [ libcanberra-gtk3 ];
|
2017-11-16 15:39:16 +00:00
|
|
|
|
2022-08-15 16:47:27 +00:00
|
|
|
launcherName = "${applicationName}${nameSuffix}";
|
|
|
|
|
2020-06-28 13:55:07 +00:00
|
|
|
#########################
|
|
|
|
# #
|
|
|
|
# EXTRA PREF CHANGES #
|
|
|
|
# #
|
|
|
|
#########################
|
2020-12-15 21:02:34 +00:00
|
|
|
policiesJson = writeText "policies.json" (builtins.toJSON enterprisePolicies);
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2020-12-04 16:53:14 +00:00
|
|
|
usesNixExtensions = nixExtensions != null;
|
|
|
|
|
2023-02-14 18:11:59 +00:00
|
|
|
nameArray = builtins.map(a: a.name) (lib.optionals usesNixExtensions nixExtensions);
|
2020-12-15 21:02:34 +00:00
|
|
|
|
firefox: Improve detecting signing requirements
Firefox 61 started to enforce signatures for add-ons and since
commit d031843a1eee244172570c64c9e238641563e68e, we get an evaluation
error that recommends the user to switch to Firefox ESR.
This isn't an option for everyone and as I also pointed out in the pull
request[1] introducing the above commit, I've been building Firefox like
this:
let
firefoxNoSigning = firefox-unwrapped.overrideAttrs (lib.const {
MOZ_REQUIRE_SIGNING = false;
});
in wrapFirefox firefoxNoSigning {
nixExtensions = ...;
}
However, this only works after manually modifying nixpkgs (or copy &
paste wrapper.nix elsewhere) every time I want to have a new Firefox
version. Of course, this gets annoying and tedious after a while, so
this motivated me to properly fix this to not only check for an ESR
version but also check the value of MOZ_REQUIRE_SIGNING.
Note that I'm using toString here to check for the value because there
are several ways (false, null, "", ...) to set the environment variable
to an empty string and toString makes sure that it really is the desired
behaviour. I specifically checked the Firefox source and also tested
this with multiple values and only building with MOZ_REQUIRE_SIGNING
set to an empty string seems to work (no "0", "false" or other
variants).
Additionally, there is another method to allow unsigned add-ons, which
is by using the --with-unsigned-addon-scopes configure option[2].
Unfortunately, this does not work with nixExtensions because we don't
have (or want) a central directory where those add-ons reside.
Given that nixExtensions disallows manually installing add-ons, setting
MOZ_REQUIRE_SIGNING to false should be safe in this case.
[1]: https://github.com/NixOS/nixpkgs/pull/133504
[2]: https://bugs.archlinux.org/task/63075
Signed-off-by: aszlig <aszlig@nix.build>
2022-06-20 23:51:31 +00:00
|
|
|
requiresSigning = browser ? MOZ_REQUIRE_SIGNING
|
|
|
|
-> toString browser.MOZ_REQUIRE_SIGNING != "";
|
|
|
|
|
2020-12-15 21:02:34 +00:00
|
|
|
# Check that every extension has a unqiue .name attribute
|
|
|
|
# and an extid attribute
|
|
|
|
extensions = if nameArray != (lib.unique nameArray) then
|
|
|
|
throw "Firefox addon name needs to be unique"
|
firefox: Improve detecting signing requirements
Firefox 61 started to enforce signatures for add-ons and since
commit d031843a1eee244172570c64c9e238641563e68e, we get an evaluation
error that recommends the user to switch to Firefox ESR.
This isn't an option for everyone and as I also pointed out in the pull
request[1] introducing the above commit, I've been building Firefox like
this:
let
firefoxNoSigning = firefox-unwrapped.overrideAttrs (lib.const {
MOZ_REQUIRE_SIGNING = false;
});
in wrapFirefox firefoxNoSigning {
nixExtensions = ...;
}
However, this only works after manually modifying nixpkgs (or copy &
paste wrapper.nix elsewhere) every time I want to have a new Firefox
version. Of course, this gets annoying and tedious after a while, so
this motivated me to properly fix this to not only check for an ESR
version but also check the value of MOZ_REQUIRE_SIGNING.
Note that I'm using toString here to check for the value because there
are several ways (false, null, "", ...) to set the environment variable
to an empty string and toString makes sure that it really is the desired
behaviour. I specifically checked the Firefox source and also tested
this with multiple values and only building with MOZ_REQUIRE_SIGNING
set to an empty string seems to work (no "0", "false" or other
variants).
Additionally, there is another method to allow unsigned add-ons, which
is by using the --with-unsigned-addon-scopes configure option[2].
Unfortunately, this does not work with nixExtensions because we don't
have (or want) a central directory where those add-ons reside.
Given that nixExtensions disallows manually installing add-ons, setting
MOZ_REQUIRE_SIGNING to false should be safe in this case.
[1]: https://github.com/NixOS/nixpkgs/pull/133504
[2]: https://bugs.archlinux.org/task/63075
Signed-off-by: aszlig <aszlig@nix.build>
2022-06-20 23:51:31 +00:00
|
|
|
else if requiresSigning && !lib.hasSuffix "esr" browser.name then
|
|
|
|
throw "Nix addons are only supported without signature enforcement (eg. Firefox ESR)"
|
2020-12-15 21:02:34 +00:00
|
|
|
else builtins.map (a:
|
2020-11-30 15:30:46 +00:00
|
|
|
if ! (builtins.hasAttr "extid" a) then
|
2020-12-04 16:53:14 +00:00
|
|
|
throw "nixExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
|
2020-11-30 15:30:46 +00:00
|
|
|
else
|
|
|
|
a
|
2023-02-14 18:11:59 +00:00
|
|
|
) (lib.optionals usesNixExtensions nixExtensions);
|
2020-06-28 13:55:07 +00:00
|
|
|
|
|
|
|
enterprisePolicies =
|
|
|
|
{
|
2022-03-06 15:54:10 +00:00
|
|
|
policies = {
|
2020-06-28 13:55:07 +00:00
|
|
|
DisableAppUpdate = true;
|
|
|
|
} //
|
2020-12-04 16:53:14 +00:00
|
|
|
lib.optionalAttrs usesNixExtensions {
|
2020-06-28 13:55:07 +00:00
|
|
|
ExtensionSettings = {
|
|
|
|
"*" = {
|
2022-06-01 00:12:26 +00:00
|
|
|
blocked_install_message = "You can't have manual extension mixed with nix extensions";
|
|
|
|
installation_mode = "blocked";
|
|
|
|
};
|
|
|
|
} // lib.foldr (e: ret:
|
|
|
|
ret // {
|
|
|
|
"${e.extid}" = {
|
|
|
|
installation_mode = "allowed";
|
2020-06-28 13:55:07 +00:00
|
|
|
};
|
2022-06-01 00:12:26 +00:00
|
|
|
}
|
|
|
|
) {} extensions;
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2022-06-01 00:12:26 +00:00
|
|
|
Extensions = {
|
|
|
|
Install = lib.foldr (e: ret:
|
|
|
|
ret ++ [ "${e.outPath}/${e.extid}.xpi" ]
|
|
|
|
) [] extensions;
|
|
|
|
};
|
|
|
|
} // lib.optionalAttrs smartcardSupport {
|
|
|
|
SecurityDevices = {
|
|
|
|
"OpenSC PKCS#11 Module" = "opensc-pkcs11.so";
|
|
|
|
};
|
|
|
|
}
|
2020-06-28 13:55:07 +00:00
|
|
|
// extraPolicies;
|
|
|
|
};
|
|
|
|
|
2022-09-07 13:36:04 +00:00
|
|
|
mozillaCfg = ''
|
2020-12-15 21:02:34 +00:00
|
|
|
// First line must be a comment
|
2020-06-28 13:55:07 +00:00
|
|
|
|
|
|
|
// Disables addon signature checking
|
|
|
|
// to be able to install addons that do not have an extid
|
|
|
|
// Security is maintained because only user whitelisted addons
|
|
|
|
// with a checksum can be installed
|
2020-12-04 16:53:14 +00:00
|
|
|
${ lib.optionalString usesNixExtensions ''lockPref("xpinstall.signatures.required", false)'' };
|
2020-06-28 13:55:07 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
#############################
|
|
|
|
# #
|
|
|
|
# END EXTRA PREF CHANGES #
|
|
|
|
# #
|
|
|
|
#############################
|
|
|
|
|
2022-02-16 20:17:30 +00:00
|
|
|
in stdenv.mkDerivation {
|
2019-11-24 17:22:28 +00:00
|
|
|
inherit pname version;
|
2017-11-16 15:39:16 +00:00
|
|
|
|
2022-10-30 06:24:34 +00:00
|
|
|
desktopItem = makeDesktopItem ({
|
2023-02-27 19:54:16 +00:00
|
|
|
name = launcherName;
|
|
|
|
exec = "${launcherName} --name ${wmClass} %U";
|
2017-11-16 15:39:16 +00:00
|
|
|
inherit icon;
|
2023-02-27 19:54:16 +00:00
|
|
|
inherit desktopName;
|
2022-10-30 06:24:34 +00:00
|
|
|
startupNotify = true;
|
2022-02-22 13:46:06 +00:00
|
|
|
startupWMClass = wmClass;
|
2022-10-30 06:24:34 +00:00
|
|
|
terminal = false;
|
|
|
|
} // (if libName == "thunderbird"
|
|
|
|
then {
|
|
|
|
genericName = "Email Client";
|
|
|
|
comment = "Read and write e-mails or RSS feeds, or manage tasks on calendars.";
|
|
|
|
categories = [
|
|
|
|
"Network" "Chat" "Email" "Feed" "GTK" "News"
|
|
|
|
];
|
|
|
|
keywords = [
|
|
|
|
"mail" "email" "e-mail" "messages" "rss" "calendar"
|
|
|
|
"address book" "addressbook" "chat"
|
|
|
|
];
|
|
|
|
mimeTypes = [
|
|
|
|
"message/rfc822"
|
|
|
|
"x-scheme-handler/mailto"
|
|
|
|
"text/calendar"
|
|
|
|
"text/x-vcard"
|
|
|
|
];
|
|
|
|
actions = {
|
|
|
|
profile-manager-window = {
|
|
|
|
name = "Profile Manager";
|
2022-11-12 09:53:07 +00:00
|
|
|
exec = "${launcherName} --ProfileManager";
|
2022-10-30 06:24:34 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
genericName = "Web Browser";
|
|
|
|
categories = [ "Network" "WebBrowser" ];
|
|
|
|
mimeTypes = [
|
|
|
|
"text/html"
|
|
|
|
"text/xml"
|
|
|
|
"application/xhtml+xml"
|
|
|
|
"application/vnd.mozilla.xul+xml"
|
|
|
|
"x-scheme-handler/http"
|
|
|
|
"x-scheme-handler/https"
|
|
|
|
];
|
|
|
|
actions = {
|
|
|
|
new-window = {
|
|
|
|
name = "New Window";
|
|
|
|
exec = "${launcherName} --new-window %U";
|
|
|
|
};
|
|
|
|
new-private-window = {
|
|
|
|
name = "New Private Window";
|
|
|
|
exec = "${launcherName} --private-window %U";
|
|
|
|
};
|
|
|
|
profile-manager-window = {
|
|
|
|
name = "Profile Manager";
|
2022-11-12 09:53:07 +00:00
|
|
|
exec = "${launcherName} --ProfileManager";
|
2022-10-30 06:24:34 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
2017-11-16 15:39:16 +00:00
|
|
|
|
2022-05-07 16:13:19 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper lndir jq ];
|
2021-07-12 13:56:03 +00:00
|
|
|
buildInputs = [ browser.gtk3 ];
|
2017-11-16 15:39:16 +00:00
|
|
|
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2022-03-21 15:03:59 +00:00
|
|
|
buildCommand = ''
|
|
|
|
if [ ! -x "${browser}/bin/${applicationName}" ]
|
2017-11-16 15:39:16 +00:00
|
|
|
then
|
2022-03-21 15:03:59 +00:00
|
|
|
echo "cannot find executable file \`${browser}/bin/${applicationName}'"
|
2017-11-16 15:39:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-06-28 13:55:07 +00:00
|
|
|
#########################
|
|
|
|
# #
|
|
|
|
# EXTRA PREF CHANGES #
|
|
|
|
# #
|
|
|
|
#########################
|
|
|
|
# Link the runtime. The executable itself has to be copied,
|
|
|
|
# because it will resolve paths relative to its true location.
|
|
|
|
# Any symbolic links have to be replicated as well.
|
|
|
|
cd "${browser}"
|
|
|
|
find . -type d -exec mkdir -p "$out"/{} \;
|
|
|
|
|
2021-07-13 17:04:57 +00:00
|
|
|
find . -type f \( -not -name "${applicationName}" \) -exec ln -sT "${browser}"/{} "$out"/{} \;
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2021-05-03 14:22:33 +00:00
|
|
|
find . -type f \( -name "${applicationName}" -o -name "${applicationName}-bin" \) -print0 | while read -d $'\0' f; do
|
|
|
|
cp -P --no-preserve=mode,ownership --remove-destination "${browser}/$f" "$out/$f"
|
2020-06-28 13:55:07 +00:00
|
|
|
chmod a+rwx "$out/$f"
|
|
|
|
done
|
|
|
|
|
|
|
|
# fix links and absolute references
|
|
|
|
|
|
|
|
find . -type l -print0 | while read -d $'\0' l; do
|
2022-05-07 16:13:19 +00:00
|
|
|
target="$(readlink "$l")"
|
|
|
|
target=''${target/#"${browser}"/"$out"}
|
2020-06-28 13:55:07 +00:00
|
|
|
ln -sfT "$target" "$out/$l"
|
|
|
|
done
|
|
|
|
|
2022-05-10 11:18:05 +00:00
|
|
|
cd "$out"
|
|
|
|
|
2020-06-28 13:55:07 +00:00
|
|
|
# create the wrapper
|
|
|
|
|
2022-03-21 15:03:59 +00:00
|
|
|
executablePrefix="$out/bin"
|
2021-07-13 17:04:57 +00:00
|
|
|
executablePath="$executablePrefix/${applicationName}"
|
2022-05-07 16:13:19 +00:00
|
|
|
oldWrapperArgs=()
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2022-05-07 16:13:19 +00:00
|
|
|
if [[ -L $executablePath ]]; then
|
|
|
|
# Symbolic link: wrap the link's target.
|
2020-06-28 13:55:07 +00:00
|
|
|
oldExe="$(readlink -v --canonicalize-existing "$executablePath")"
|
2022-05-07 16:13:19 +00:00
|
|
|
rm "$executablePath"
|
2022-05-11 20:00:24 +00:00
|
|
|
elif wrapperCmd=$(${makeBinaryWrapper.extractCmd} "$executablePath"); [[ $wrapperCmd ]]; then
|
2022-05-07 16:13:19 +00:00
|
|
|
# If the executable is a binary wrapper, we need to update its target to
|
|
|
|
# point to $out, but we can't just edit the binary in-place because of length
|
|
|
|
# issues. So we extract the command used to create the wrapper and add the
|
|
|
|
# arguments to our wrapper.
|
|
|
|
parseMakeCWrapperCall() {
|
|
|
|
shift # makeCWrapper
|
|
|
|
oldExe=$1; shift
|
2022-05-10 14:10:12 +00:00
|
|
|
oldWrapperArgs=("$@")
|
2022-05-07 16:13:19 +00:00
|
|
|
}
|
|
|
|
eval "parseMakeCWrapperCall ''${wrapperCmd//"${browser}"/"$out"}"
|
|
|
|
rm "$executablePath"
|
|
|
|
else
|
|
|
|
if read -rn2 shebang < "$executablePath" && [[ $shebang == '#!' ]]; then
|
|
|
|
# Shell wrapper: patch in place to point to $out.
|
|
|
|
sed -i "s@${browser}@$out@g" "$executablePath"
|
|
|
|
fi
|
|
|
|
# Suffix the executable with -old, because -wrapped might already be used by the old wrapper.
|
|
|
|
oldExe="$executablePrefix/.${applicationName}"-old
|
|
|
|
mv "$executablePath" "$oldExe"
|
2020-06-28 13:55:07 +00:00
|
|
|
fi
|
|
|
|
|
2022-07-11 23:23:52 +00:00
|
|
|
# make xdg-open overrideable at runtime
|
2020-06-28 13:55:07 +00:00
|
|
|
makeWrapper "$oldExe" \
|
2022-05-07 16:13:19 +00:00
|
|
|
"''${executablePath}${nameSuffix}" \
|
2021-04-14 15:52:28 +00:00
|
|
|
--prefix LD_LIBRARY_PATH ':' "$libs" \
|
2017-11-16 15:39:16 +00:00
|
|
|
--suffix-each GTK_PATH ':' "$gtk_modules" \
|
2022-07-11 23:23:52 +00:00
|
|
|
--suffix PATH ':' "${xdg-utils}/bin" \
|
2022-03-21 15:03:59 +00:00
|
|
|
--suffix PATH ':' "$out/bin" \
|
2022-08-15 16:47:27 +00:00
|
|
|
--set MOZ_APP_LAUNCHER "${launcherName}" \
|
2017-11-16 15:39:16 +00:00
|
|
|
--set MOZ_SYSTEM_DIR "$out/lib/mozilla" \
|
2019-09-04 00:09:39 +00:00
|
|
|
--set MOZ_LEGACY_PROFILES 1 \
|
|
|
|
--set MOZ_ALLOW_DOWNGRADE 1 \
|
2021-07-12 13:56:03 +00:00
|
|
|
--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
|
|
|
|
--suffix XDG_DATA_DIRS : '${gnome.adwaita-icon-theme}/share' \
|
2022-11-15 19:11:57 +00:00
|
|
|
--set-default MOZ_ENABLE_WAYLAND 1 \
|
2022-05-07 16:13:19 +00:00
|
|
|
"''${oldWrapperArgs[@]}"
|
2020-06-28 13:55:07 +00:00
|
|
|
#############################
|
|
|
|
# #
|
|
|
|
# END EXTRA PREF CHANGES #
|
|
|
|
# #
|
|
|
|
#############################
|
2017-11-16 15:39:16 +00:00
|
|
|
|
|
|
|
if [ -e "${browser}/share/icons" ]; then
|
|
|
|
mkdir -p "$out/share"
|
|
|
|
ln -s "${browser}/share/icons" "$out/share/icons"
|
|
|
|
else
|
2018-03-22 16:42:25 +00:00
|
|
|
for res in 16 32 48 64 128; do
|
|
|
|
mkdir -p "$out/share/icons/hicolor/''${res}x''${res}/apps"
|
2021-11-14 04:54:00 +00:00
|
|
|
icon=$( find "${browser}/lib/" -name "default''${res}.png" )
|
2018-04-23 07:33:09 +00:00
|
|
|
if [ -e "$icon" ]; then ln -s "$icon" \
|
2022-03-21 15:03:59 +00:00
|
|
|
"$out/share/icons/hicolor/''${res}x''${res}/apps/${icon}.png"
|
2018-04-23 07:33:09 +00:00
|
|
|
fi
|
2018-03-22 16:42:25 +00:00
|
|
|
done
|
2017-11-16 15:39:16 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
install -D -t $out/share/applications $desktopItem/share/applications/*
|
|
|
|
|
2020-02-05 22:29:52 +00:00
|
|
|
mkdir -p $out/lib/mozilla/native-messaging-hosts
|
2017-11-16 15:39:16 +00:00
|
|
|
for ext in ${toString nativeMessagingHosts}; do
|
2020-02-05 22:29:52 +00:00
|
|
|
ln -sLt $out/lib/mozilla/native-messaging-hosts $ext/lib/mozilla/native-messaging-hosts/*
|
2017-11-16 15:39:16 +00:00
|
|
|
done
|
|
|
|
|
2020-07-04 08:04:30 +00:00
|
|
|
mkdir -p $out/lib/mozilla/pkcs11-modules
|
|
|
|
for ext in ${toString pkcs11Modules}; do
|
|
|
|
ln -sLt $out/lib/mozilla/pkcs11-modules $ext/lib/mozilla/pkcs11-modules/*
|
|
|
|
done
|
|
|
|
|
2020-06-28 13:55:07 +00:00
|
|
|
|
|
|
|
#########################
|
|
|
|
# #
|
|
|
|
# EXTRA PREF CHANGES #
|
|
|
|
# #
|
|
|
|
#########################
|
|
|
|
# user customization
|
2021-07-13 17:04:57 +00:00
|
|
|
mkdir -p $out/lib/${libName}
|
2020-06-28 13:55:07 +00:00
|
|
|
|
|
|
|
# creating policies.json
|
2021-07-13 17:04:57 +00:00
|
|
|
mkdir -p "$out/lib/${libName}/distribution"
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2021-07-13 17:04:57 +00:00
|
|
|
POL_PATH="$out/lib/${libName}/distribution/policies.json"
|
2020-06-28 13:55:07 +00:00
|
|
|
rm -f "$POL_PATH"
|
|
|
|
cat ${policiesJson} >> "$POL_PATH"
|
|
|
|
|
2022-02-11 18:05:45 +00:00
|
|
|
extraPoliciesFiles=(${builtins.toString extraPoliciesFiles})
|
|
|
|
for extraPoliciesFile in "''${extraPoliciesFiles[@]}"; do
|
|
|
|
jq -s '.[0] + .[1]' "$POL_PATH" $extraPoliciesFile > .tmp.json
|
|
|
|
mv .tmp.json "$POL_PATH"
|
|
|
|
done
|
|
|
|
|
2020-06-28 13:55:07 +00:00
|
|
|
# preparing for autoconfig
|
2021-07-13 17:04:57 +00:00
|
|
|
mkdir -p "$out/lib/${libName}/defaults/pref"
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2021-07-13 17:04:57 +00:00
|
|
|
echo 'pref("general.config.filename", "mozilla.cfg");' > "$out/lib/${libName}/defaults/pref/autoconfig.js"
|
|
|
|
echo 'pref("general.config.obscure_value", 0);' >> "$out/lib/${libName}/defaults/pref/autoconfig.js"
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2022-09-07 13:36:04 +00:00
|
|
|
cat > "$out/lib/${libName}/mozilla.cfg" << EOF
|
|
|
|
${mozillaCfg}
|
|
|
|
EOF
|
2020-06-28 13:55:07 +00:00
|
|
|
|
2022-02-11 18:05:45 +00:00
|
|
|
extraPrefsFiles=(${builtins.toString extraPrefsFiles})
|
|
|
|
for extraPrefsFile in "''${extraPrefsFiles[@]}"; do
|
|
|
|
cat "$extraPrefsFile" >> "$out/lib/${libName}/mozilla.cfg"
|
|
|
|
done
|
|
|
|
|
2022-09-07 13:36:04 +00:00
|
|
|
cat >> "$out/lib/${libName}/mozilla.cfg" << EOF
|
|
|
|
${extraPrefs}
|
|
|
|
EOF
|
|
|
|
|
2021-07-13 17:04:57 +00:00
|
|
|
mkdir -p $out/lib/${libName}/distribution/extensions
|
2020-06-28 13:55:07 +00:00
|
|
|
|
|
|
|
#############################
|
|
|
|
# #
|
|
|
|
# END EXTRA PREF CHANGES #
|
|
|
|
# #
|
|
|
|
#############################
|
2017-11-16 15:39:16 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
libs = lib.makeLibraryPath libs + ":" + lib.makeSearchPathOutput "lib" "lib64" libs;
|
|
|
|
gtk_modules = map (x: x + x.gtkModule) gtk_modules;
|
|
|
|
|
|
|
|
passthru = { unwrapped = browser; };
|
|
|
|
|
|
|
|
disallowedRequisites = [ stdenv.cc ];
|
|
|
|
|
|
|
|
meta = browser.meta // {
|
2023-02-27 19:54:16 +00:00
|
|
|
inherit (browser.meta) description;
|
2017-11-16 15:39:16 +00:00
|
|
|
hydraPlatforms = [];
|
|
|
|
priority = (browser.meta.priority or 0) - 1; # prefer wrapper over the package
|
|
|
|
};
|
2022-02-16 20:17:30 +00:00
|
|
|
};
|
2021-02-09 08:11:44 +00:00
|
|
|
in lib.makeOverridable wrapper
|