From 6e7fd3d6c24e1a0ea0c4b7304d483e899befdb4b Mon Sep 17 00:00:00 2001 From: dongsu8142 Date: Sun, 23 Jul 2023 16:02:53 +0900 Subject: [PATCH] feat(pkgs): added naver-whale --- default.nix | 2 +- flake.nix | 10 +-- pkgs/naver-whale/default.nix | 158 +++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 pkgs/naver-whale/default.nix diff --git a/default.nix b/default.nix index c333f23..7c55593 100644 --- a/default.nix +++ b/default.nix @@ -15,6 +15,6 @@ overlays = import ./overlays; # nixpkgs overlays gtk-gjs = pkgs.callPackage ./pkgs/gtk-gjs { }; - # some-qt5-package = pkgs.libsForQt5.callPackage ./pkgs/some-qt5-package { }; + naver-whale = pkgs.libsForQt5.callPackage ./pkgs/naver-whale { }; # ... } diff --git a/flake.nix b/flake.nix index 81a143f..53468e5 100644 --- a/flake.nix +++ b/flake.nix @@ -5,11 +5,11 @@ let systems = [ "x86_64-linux" - "i686-linux" - "x86_64-darwin" - "aarch64-linux" - "armv6l-linux" - "armv7l-linux" + # "i686-linux" + # "x86_64-darwin" + # "aarch64-linux" + # "armv6l-linux" + # "armv7l-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); in diff --git a/pkgs/naver-whale/default.nix b/pkgs/naver-whale/default.nix new file mode 100644 index 0000000..2f52f07 --- /dev/null +++ b/pkgs/naver-whale/default.nix @@ -0,0 +1,158 @@ +{ lib, stdenv, fetchurl, wrapGAppsHook, makeWrapper +, alsa-lib +, at-spi2-atk +, at-spi2-core +, atk +, cairo +, cups +, dbus +, dpkg +, expat +, fontconfig +, freetype +, gdk-pixbuf +, glib +, gnome +, gsettings-desktop-schemas +, gtk3 +, libX11 +, libXScrnSaver +, libXcomposite +, libXcursor +, libXdamage +, libXext +, libXfixes +, libXi +, libXrandr +, libXrender +, libXtst +, libdrm +, libkrb5 +, libuuid +, libxkbcommon +, libxshmfence +, mesa +, nspr +, nss +, pango +, pipewire +, snappy +, udev +, wayland +, xdg-utils +, xorg +, zlib +, libpulseaudio +, libGL +, libva +}: +let + version = "3.21.192.18"; + deps = [ + alsa-lib at-spi2-atk at-spi2-core atk cairo cups dbus expat + fontconfig freetype gdk-pixbuf glib gtk3 libdrm xorg.libX11 libGL + libxkbcommon xorg.libXScrnSaver xorg.libXcomposite xorg.libXcursor xorg.libXdamage + xorg.libXext xorg.libXfixes xorg.libXi xorg.libXrandr xorg.libXrender xorg.libxshmfence + xorg.libXtst libuuid mesa nspr nss pango pipewire udev wayland + xorg.libxcb zlib snappy libkrb5 libpulseaudio libva + ]; + rpath = lib.makeLibraryPath deps + ":" + lib.makeSearchPathOutput "lib" "lib64" deps; + binpath = lib.makeBinPath deps; + enableFeatures = lib.optionals stdenv.isLinux [ "VaapiVideoDecoder" "VaapiVideoEncoder" ]; + disableFeatures = lib.optional stdenv.isLinux "UseChromeOSDirectVideoDecoder"; +in +stdenv.mkDerivation { + pname = "naver-whale"; + inherit version; + + src = fetchurl { + url = "https://repo.whale.naver.com/stable/deb/pool/main/n/naver-whale-stable/naver-whale-stable_${version}-1_amd64.deb"; + sha256 = "sha256-cPmfR8JwLpnk63hgAo/N/pqpE3e47tXBQYT5gllApkk="; + }; + + dontConfigure = true; + dontBuild = true; + dontPatchELF = true; + doInstallCheck = true; + + nativeBuildInputs = [ + dpkg + wrapGAppsHook + ]; + + buildInputs = [ + glib gsettings-desktop-schemas gtk3 + gnome.adwaita-icon-theme + ]; + + unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner"; + + installPhase = '' + runHook preInstall + mkdir -p $out $out/bin + cp -R usr/share $out + cp -R opt/ $out/opt + echo ${rpath} + + export BINARYWRAPPER=$out/opt/naver/whale/naver-whale + + substituteInPlace $BINARYWRAPPER \ + --replace /bin/bash ${stdenv.shell} + + ln -sf $BINARYWRAPPER $out/bin/naver-whale + + for exe in $out/opt/naver/whale/{whale,chrome_crashpad_handler}; do + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${rpath}" $exe + done + + substituteInPlace $out/share/applications/naver-whale.desktop \ + --replace /usr/bin/naver-whale $out/bin/naver-whale + substituteInPlace $out/share/gnome-control-center/default-apps/naver-whale.xml \ + --replace /opt/naver $out/opt/naver + substituteInPlace $out/share/menu/naver-whale.menu \ + --replace /opt/naver $out/opt/naver + substituteInPlace $out/opt/naver/whale/default-app-block \ + --replace /opt/naver $out/opt/naver + + icon_sizes=("16" "24" "32" "48" "64" "128" "256") + + for icon in ''${icon_sizes[*]} + do + mkdir -p $out/share/icons/hicolor/$icon\x$icon/apps + ln -s $out/opt/naver/whale/product_logo_$icon.png $out/share/icons/hicolor/$icon\x$icon/apps/naver-whale.png + done + ln -sf ${xdg-utils}/bin/xdg-settings $out/opt/naver/whale/xdg-settings + ln -sf ${xdg-utils}/bin/xdg-mime $out/opt/naver/whale/xdg-mime + + runHook postInstall + ''; + + preFixup = '' + # Add command line args to wrapGApp. + gappsWrapperArgs+=( + --prefix LD_LIBRARY_PATH : ${rpath} + --prefix PATH : ${binpath} + --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} + ${lib.optionalString (enableFeatures != []) '' + --add-flags "--enable-features=${lib.strings.concatStringsSep "," enableFeatures}" + ''} + ${lib.optionalString (disableFeatures != []) '' + --add-flags "--disable-features=${lib.strings.concatStringsSep "," disableFeatures}" + ''} + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" + ) + ''; + + installCheckPhase = '' + # Bypass upstream wrapper which suppresses errors + $out/opt/naver/whale/naver-whale --version + ''; + + meta = with lib; { + description = "The web browser from NAVER"; + homepage = "https://whale.naver.com"; + platforms = [ "x86_64-linux" ]; + }; +}