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 home.packages = let
escapeDesktopArg = arg: escapeDesktopArg = arg:
replaceStrings [ ''"'' ] [ ''"\""'' ] (toString arg); replaceStrings [ ''"'' ] [ ''"\""'' ] (toString arg);
makeFirefoxProfileDesktopItem = attrs: makeFirefoxProfileBin = args@{ profile, ... }:
let let
mkExec = with lib; name = "firefox-${profile}";
{ name, profile, ... }: '' script = ''
firefox -p "${escapeDesktopArg profile}" --class="firefox-${ firefox -p "${escapeDesktopArg profile}" --class="${
escapeDesktopArg name escapeDesktopArg name
}" }"'';
''; scriptBin = pkgs.writeScriptBin name ''
in pkgs.makeDesktopItem ((removeAttrs attrs [ "profile" ]) // { ${script} $@
exec = mkExec attrs;
extraEntries = ''
StartupWMClass="${escapeDesktopArg attrs.name}"
''; '';
}); desktopFile = pkgs.makeDesktopItem ((removeAttrs args [ "profile" ])
// {
inherit name;
exec = "${scriptBin}/bin/${name} %U";
extraEntries = ''
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; in (with pkgs;
[ (tor-browser-bundle-bin.override { pulseaudioSupport = true; }) ]) ++ [ [ (tor-browser-bundle-bin.override { pulseaudioSupport = true; }) ]) ++ [
(makeFirefoxProfileDesktopItem { (makeFirefoxProfileBin {
name = "firefox-work";
desktopName = "Firefox (Work)";
icon = "firefox"; # TODO looks different
profile = "work"; profile = "work";
desktopName = "Firefox (Work)";
icon = "firefox";
}) })
]; ];
} }