feat(browsers): add firefox profile binaries

This commit is contained in:
Felix Schröter 2021-03-29 21:39:37 +02:00
parent ddc159417a
commit fb396ce0d8
No known key found for this signature in database
GPG key ID: 910ACB9F6BD26F58

View file

@ -97,27 +97,46 @@ in {
home.packages = let
escapeDesktopArg = arg:
replaceStrings [ ''"'' ] [ ''"\""'' ] (toString arg);
makeFirefoxProfileDesktopItem = attrs:
makeFirefoxProfileBin = args@{ profile, ... }:
let
mkExec = with lib;
{ name, profile, ... }: ''
firefox -p "${escapeDesktopArg profile}" --class="firefox-${
name = "firefox-${profile}";
script = ''
firefox -p "${escapeDesktopArg profile}" --class="${
escapeDesktopArg name
}"
}"'';
scriptBin = pkgs.writeScriptBin name ''
${script} $@
'';
in pkgs.makeDesktopItem ((removeAttrs attrs [ "profile" ]) // {
exec = mkExec attrs;
desktopFile = pkgs.makeDesktopItem ((removeAttrs args [ "profile" ])
// {
inherit name;
exec = "${scriptBin}/bin/${name} %U";
extraEntries = ''
StartupWMClass="${escapeDesktopArg attrs.name}"
StartupWMClass="${escapeDesktopArg name}"
'';
genericName = "Web Browser";
mimeType = lib.concatStringsSep ";" [
"text/html"
"text/xml"
"application/xhtml+xml"
"application/vnd.mozilla.xul+xml"
"x-scheme-handler/http"
"x-scheme-handler/https"
"x-scheme-handler/ftp"
];
categories = "Network;WebBrowser;";
});
in pkgs.runCommand name { } ''
mkdir -p $out/{bin,share}
cp -r ${scriptBin}/bin/${name} $out/bin/${name}
cp -r ${desktopFile}/share/applications $out/share/applications
'';
in (with pkgs;
[ (tor-browser-bundle-bin.override { pulseaudioSupport = true; }) ]) ++ [
(makeFirefoxProfileDesktopItem {
name = "firefox-work";
desktopName = "Firefox (Work)";
icon = "firefox"; # TODO looks different
(makeFirefoxProfileBin {
profile = "work";
desktopName = "Firefox (Work)";
icon = "firefox";
})
];
}