Commit eecf05db authored by Ihar Hrachyshka's avatar Ihar Hrachyshka
Browse files

firefox-bin: enable for darwin

parent 8d7c693f
Loading
Loading
Loading
Loading
+43 −21
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
  systemLocale ? config.i18n.defaultLocale or "en_US",
  patchelfUnstable, # have to use patchelfUnstable to support --no-clobber-old-sections
  applicationName ? "Firefox",
  undmg,
}:

let
@@ -39,6 +40,9 @@ let
    i686-linux = "linux-i686";
    x86_64-linux = "linux-x86_64";
    aarch64-linux = "linux-aarch64";
    # bundles are universal and can be re-used for both darwin architectures
    aarch64-darwin = "mac";
    x86_64-darwin = "mac";
  };

  arch = mozillaPlatforms.${stdenv.hostPlatform.system};
@@ -71,30 +75,48 @@ stdenv.mkDerivation {

  src = fetchurl { inherit (source) url sha256; };

  nativeBuildInputs = [
  sourceRoot = lib.optional stdenv.hostPlatform.isDarwin ".";

  nativeBuildInputs =
    [
      wrapGAppsHook3
    ]
    ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
      autoPatchelfHook
      patchelfUnstable
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      undmg
    ];
  buildInputs = [
  buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [
    gtk3
    adwaita-icon-theme
    alsa-lib
    dbus-glib
    libXtst
  ];
  runtimeDependencies = [
  runtimeDependencies =
    [
      curl
    libva.out
      pciutils
    ]
    ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
      libva.out
    ];
  appendRunpaths = [
  appendRunpaths = lib.optionals (!stdenv.hostPlatform.isDarwin) [
    "${pipewire}/lib"
  ];
  # Firefox uses "relrhack" to manually process relocations from a fixed offset
  patchelfFlags = [ "--no-clobber-old-sections" ];

  installPhase = ''
  installPhase =
    if stdenv.hostPlatform.isDarwin then
      ''
        mkdir -p $out/Applications
        mv Firefox.app $out/Applications
      ''
    else
      ''
        mkdir -p "$prefix/lib/firefox-bin-${version}"
        cp -r * "$prefix/lib/firefox-bin-${version}"

+618 −0

File changed.

Preview size limit exceeded, changes collapsed.

+6 −5
Original line number Diff line number Diff line
@@ -60,27 +60,28 @@ writeScript "update-${pname}" ''

  # this is a list of sha256 and tarballs for both arches
  # Upstream files contains python repr strings like b'somehash', hence the sed dance
  shasums=`cat $HOME/shasums | sed -E s/"b'([a-f0-9]{64})'?(.*)"/'\1\2'/ | grep '\.tar\.[a-z0-9]\+'`
  shasums=`cat $HOME/shasums | sed -E s/"b'([a-f0-9]{64})'?(.*)"/'\1\2'/ | grep '\.\(tar\.[a-z0-9]\+\|dmg\)$' | grep -v mac-EME-free`

  cat > $tmpfile <<EOF
  {
    version = "$version";
    sources = [
  EOF
  for arch in linux-x86_64 linux-i686 linux-aarch64; do
  for arch in linux-x86_64 linux-i686 linux-aarch64 mac; do
    # retriving a list of all tarballs for each arch
    #  - only select tarballs for current arch
    #  - only select tarballs for current version
    #  - rename space with colon so that for loop doesnt
    #  - inteprets sha and path as 2 lines
    IFS=$'\n'
    for line in `echo "$shasums" | \
                 grep $arch | \
                 grep "${baseName}-$version"'\.tar\.[a-z0-9]\+$' | \
                 tr " " ":"`; do
                 grep -i "${baseName}.$version"'\.\(tar\.[a-z0-9]\+\|dmg\)$' | \
                 sed "s/ /:/ ; s/ /:/"`; do
      # create an entry for every locale
      cat >> $tmpfile <<EOF
      {
        url = "$url$version/`echo $line | cut -d":" -f3`";
        url = "$url$version/`echo $line | cut -d":" -f3 | sed "s/ /%20/"`";
        locale = "`echo $line | cut -d":" -f3 | sed "s/$arch\///" | sed "s/\/.*//"`";
        arch = "$arch";
        sha256 = "`echo $line | cut -d":" -f1`";