From 7467b40e30b9954a7e75fe0afb704971a4b22249 Mon Sep 17 00:00:00 2001 From: imnyang Date: Thu, 19 Mar 2026 18:00:44 +0900 Subject: [PATCH] wow --- .gitignore | 1 + README.md | 23 +++ flake.lock | 27 +++ flake.nix | 19 ++ pkgs/waterfox-bin/default.nix | 215 +++++++++++++++++++++++ pkgs/waterfox/default.nix | 90 ++++++++++ pkgs/waterfox/remove-missing-icons.patch | 18 ++ 7 files changed, 393 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 pkgs/waterfox-bin/default.nix create mode 100644 pkgs/waterfox/default.nix create mode 100644 pkgs/waterfox/remove-missing-icons.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2f5dd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..322b0b8 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# imnyang Nix Packages +imnyang's custom nixpkgs overlay. + +## Usage +Add the following to your nix configuration: + +```nix +{ + inputs = { + nixpkgs.url = "..."; + imnyang.url = "git+https://git.mizuki.guru/imnyang/nix-packages.git"; + }; + + outputs = { imnyang, nixpkgs, ... }: + let pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ imnyang.overlays.default ]; + }; + { + # use some packages + }; +} + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..347f44c --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1773734432, + "narHash": "sha256-IF5ppUWh6gHGHYDbtVUyhwy/i7D261P7fWD1bPefOsw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cda48547b432e8d3b18b4180ba07473762ec8558", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ddd254c --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "imnyang's nix packages"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { + packages.${system} = { + waterfox = pkgs.callPackage ./pkgs/waterfox/default.nix { }; + waterfox-bin = pkgs.callPackage ./pkgs/waterfox-bin/default.nix { }; + default = self.packages.${system}.waterfox-bin; + }; + }; +} diff --git a/pkgs/waterfox-bin/default.nix b/pkgs/waterfox-bin/default.nix new file mode 100644 index 0000000..6a05fe3 --- /dev/null +++ b/pkgs/waterfox-bin/default.nix @@ -0,0 +1,215 @@ +/** + * @name waterfox-bin + * @author joyfulcat + * @source https://github.com/joyfulcat/nixpkgs/blob/e1916bfd30fde149d32b41f8f6bdad32bd2e70ce/pkgs/by-name/wa/waterfox/package.nix +*/ +{ + lib, + stdenv, + fetchurl, + wrapGAppsHook3, + alsa-lib, + at-spi2-atk, + at-spi2-core, + atk, + cairo, + cups, + dbus-glib, + libnotify, + libdrm, + libxkbcommon, + mesa, + nspr, + nss, + pango, + systemd, + libpulseaudio, + gdk-pixbuf, + gtk3, + makeDesktopItem, + unzip, + libX11, + libXScrnSaver, + libXcomposite, + libXcursor, + libXdamage, + libXext, + libXfixes, + libXi, + libXrandr, + libXrender, + libXtst, + libxcb, + writeText, + patchelf, + makeWrapper, + libGL, + ffmpeg, + glib, + pciutils, +}: + +let + version = "6.6.9"; + + desktopItem = makeDesktopItem { + name = "waterfox"; + exec = "waterfox %U"; + icon = "waterfox"; + desktopName = "Waterfox"; + 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" + "x-scheme-handler/ftp" + ]; + }; + + prefsFile = writeText "waterfox-prefs.js" '' + // Disable automatic updates and notifications + pref("app.update.auto", false); + pref("app.update.enabled", false); + pref("browser.crashReports.unsubmittedCheck.enabled", false); + ''; + +in +stdenv.mkDerivation (finalAttrs: { + pname = "waterfox"; + version = version; + + src = fetchurl { + url = "https://cdn1.waterfox.net/waterfox/releases/${finalAttrs.version}/Linux_x86_64/waterfox-${finalAttrs.version}.tar.bz2"; + hash = "sha256-rm0scyOkBLKXPtH3tTx4yBwX/swNGGZlWeQ00zDJQAw="; + }; + + nativeBuildInputs = [ + wrapGAppsHook3 + unzip + patchelf + makeWrapper + ]; + + buildInputs = [ + alsa-lib + at-spi2-atk + at-spi2-core + atk + cairo + cups + dbus-glib + libnotify + libdrm + libxkbcommon + mesa + nspr + nss + pango + systemd + libpulseaudio + gdk-pixbuf + gtk3 + libX11 + libXScrnSaver + libXcomposite + libXcursor + libXdamage + libXext + libXfixes + libXi + libXrandr + libXrender + libXtst + libxcb + stdenv.cc.cc.lib + libGL + ffmpeg + glib + pciutils + ]; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,opt,share/applications} + cp -r . $out/opt/waterfox + + makeWrapper $out/opt/waterfox/waterfox-bin $out/bin/waterfox \ + --set GTK_IM_MODULE gtk-im-context-simple \ + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath finalAttrs.buildInputs}" + + cp ${desktopItem}/share/applications/* $out/share/applications/ + + mkdir -p $out/share/icons/hicolor/256x256/apps + cp $out/opt/waterfox/browser/chrome/icons/default/default256.png \ + $out/share/icons/hicolor/256x256/apps/waterfox.png + + mkdir -p $out/opt/waterfox/browser/defaults/preferences + cp ${prefsFile} $out/opt/waterfox/browser/defaults/preferences/nix-prefs.js + + runHook postInstall + ''; + + postInstall = '' + find $out/opt/waterfox -type f -name "*.so" -exec sh -c ' + if patchelf --print-interpreter "{}" >/dev/null 2>&1; then + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${lib.makeLibraryPath finalAttrs.buildInputs}:$out/opt/waterfox" \ + "{}" + fi + ' \; + + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${lib.makeLibraryPath finalAttrs.buildInputs}:$out/opt/waterfox" \ + $out/opt/waterfox/waterfox-bin + + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${lib.makeLibraryPath finalAttrs.buildInputs}:$out/opt/waterfox" \ + $out/opt/waterfox/glxtest + + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${lib.makeLibraryPath finalAttrs.buildInputs}:$out/opt/waterfox" \ + $out/opt/waterfox/vaapitest + + cp -L ${nspr}/lib/libnspr4.so $out/opt/waterfox/ + cp -L ${nspr}/lib/libplc4.so $out/opt/waterfox/ + cp -L ${nspr}/lib/libplds4.so $out/opt/waterfox/ + + for lib in ${nss}/lib/lib{nss3,nssutil3,smime3,ssl3}.so; do + if [ ! -e $out/opt/waterfox/$(basename $lib) ]; then + cp -L $lib $out/opt/waterfox/ + fi + done + ''; + + preFixup = '' + gappsWrapperArgs+=( + --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:$out/share" + ) + ''; + + meta = { + description = "Privacy-focused, multi-platform web browser"; + homepage = "https://www.waterfox.net/"; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + license = lib.licenses.mpl20; + platforms = [ "x86_64-linux" ]; + maintainers = with lib.maintainers; [ + joyfulcat + ]; + }; +}) \ No newline at end of file diff --git a/pkgs/waterfox/default.nix b/pkgs/waterfox/default.nix new file mode 100644 index 0000000..67e0117 --- /dev/null +++ b/pkgs/waterfox/default.nix @@ -0,0 +1,90 @@ +/** + * @name waterfox + * @author paring + * @source https://git.pari.ng/paring/nix-packages/src/commit/2a2a6be44cc2ffc6b51a609732e506ed9964a1bb/pkg/waterfox +*/ +{ + apple-sdk_15, + fetchFromGitHub, + lib, + nixosTests, + nix-update-script, + sccache, + stdenv, + buildMozillaMach, +}: +let + waterfox = buildMozillaMach rec { + pname = "waterfox"; + version = "6.6.9"; + applicationName = "Waterfox"; + binaryName = "waterfox"; + branding = "waterfox/browser/branding"; + src = fetchFromGitHub { + owner = "BrowserWorks"; + repo = "Waterfox"; + tag = version; + hash = "sha256-mrbXjztb4+qUnXEB/WrXN0x6AiBjz7yPqLwTuqeQfUg="; + fetchSubmodules = true; + preFetch = '' + export GIT_CONFIG_COUNT=1 + export GIT_CONFIG_KEY_0=url.https://github.com/.insteadOf + export GIT_CONFIG_VALUE_0=git@github.com: + ''; # We can't clone with SSH here + }; + + extraBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ + apple-sdk_15 # Browser requires sdk 15+ to work on darwin + ]; + + extraConfigureFlags = [ + "--with-app-basename=${applicationName}" + ]; + + extraPatches = [ + ./remove-missing-icons.patch + ]; # Some of the icons are missing and cause the build to crash. Removing them fixes the issue + + extraPostPatch = '' + rm .mozconfig .mozconfig-* + + echo 'export CCACHE_CPP2=yes' >> .mozconfig + echo 'export RUSTC_WRAPPER=sccache' >> .mozconfig + echo 'ac_add_options --with-ccache=sccache' >> .mozconfig + ''; # buildMozillaMach will take care of the build arguments + + meta = { + broken = stdenv.buildPlatform.is32bit; + # since Firefox 60, build on 32-bit platforms fails with "out of memory". + # not in `badPlatforms` because cross-compilation on 64-bit machine might work. + changelog = "https://github.com/BrowserWorks/waterfox/releases/tag/${version}"; + description = "A privacy-focused Firefox Fork"; + homepage = "https://www.waterfox.com"; + license = lib.licenses.mpl20; + mainProgram = "waterfox"; + # maintainers = with lib.maintainers; [ + # aurelivia + # ethancedwards8 # Darwin + # hythera + # ]; + maxSilent = 14400; # 4h, double the default of 7200s (c.f. #129212, #129115) + platforms = lib.platforms.unix; + }; + tests = { inherit (nixosTests) waterfox; }; + updateScript = nix-update-script { }; + }; +in +waterfox.overrideAttrs (prev: { + nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ [ + sccache + ]; + + preConfigure = (prev.preConfigure or "") + '' + export SCCACHE_DIR=/var/cache/sccache/waterfox + export SCCACHE_IDLE_TIMEOUT=0 + export SCCACHE_CACHE_SIZE=64G + export SCCACHE_ERROR_LOG=/var/cache/sccache/waterfox.log + + sccache -s + ''; +}) diff --git a/pkgs/waterfox/remove-missing-icons.patch b/pkgs/waterfox/remove-missing-icons.patch new file mode 100644 index 0000000..1f09fef --- /dev/null +++ b/pkgs/waterfox/remove-missing-icons.patch @@ -0,0 +1,18 @@ +diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in +index 64d9993530c3..8f107b65c5be 100644 +--- a/browser/installer/package-manifest.in ++++ b/browser/installer/package-manifest.in +@@ -222,13 +222,10 @@ + @RESPATH@/chrome/toolkit.manifest + #ifdef MOZ_GTK + @RESPATH@/browser/chrome/icons/default/default16.png +-@RESPATH@/browser/chrome/icons/default/default22.png +-@RESPATH@/browser/chrome/icons/default/default24.png + @RESPATH@/browser/chrome/icons/default/default32.png + @RESPATH@/browser/chrome/icons/default/default48.png + @RESPATH@/browser/chrome/icons/default/default64.png + @RESPATH@/browser/chrome/icons/default/default128.png +-@RESPATH@/browser/chrome/icons/default/default256.png + #endif + + ; [DevTools Startup Files]