From 21edf9c42f6e2da542fa82a533afb95e83a75a35 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sat, 28 Aug 2021 23:12:27 +0200 Subject: [PATCH] chromium: Move the version helper functions into default.nix Those functions can be required anywhere in the Nix expressions for Chromium and therefore they should be defined in default.nix and inherited where necessary. This fixes the chromiumBeta build which failed because I forgot to update the channel conditional when the beta channel advanced to M94. This is exactly why the version based conditionals should be used everywhere. (cherry picked from commit 186315def77d62b53ad6ccdf57ec9593edbe8bc3) --- .../networking/browsers/chromium/browser.nix | 9 ++++-- .../networking/browsers/chromium/common.nix | 14 ++------- .../networking/browsers/chromium/default.nix | 30 +++++++++++++++---- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/pkgs/applications/networking/browsers/chromium/browser.nix b/pkgs/applications/networking/browsers/chromium/browser.nix index 26c2909da54..8b80f8f8a6e 100644 --- a/pkgs/applications/networking/browsers/chromium/browser.nix +++ b/pkgs/applications/networking/browsers/chromium/browser.nix @@ -1,4 +1,7 @@ -{ lib, mkChromiumDerivation, channel, enableWideVine, ungoogled }: +{ lib, mkChromiumDerivation +, channel, chromiumVersionAtLeast +, enableWideVine, ungoogled +}: with lib; @@ -16,8 +19,8 @@ mkChromiumDerivation (base: rec { cp -v "$buildPath/"*.so "$buildPath/"*.pak "$buildPath/"*.bin "$libExecPath/" cp -v "$buildPath/icudtl.dat" "$libExecPath/" cp -vLR "$buildPath/locales" "$buildPath/resources" "$libExecPath/" - ${lib.optionalString (channel != "dev") ''cp -v "$buildPath/crashpad_handler" "$libExecPath/"''} - ${lib.optionalString (channel == "dev") ''cp -v "$buildPath/chrome_crashpad_handler" "$libExecPath/"''} + ${lib.optionalString (!chromiumVersionAtLeast "94") ''cp -v "$buildPath/crashpad_handler" "$libExecPath/"''} + ${lib.optionalString (chromiumVersionAtLeast "94") ''cp -v "$buildPath/chrome_crashpad_handler" "$libExecPath/"''} cp -v "$buildPath/chrome" "$libExecPath/$packageName" # Swiftshader diff --git a/pkgs/applications/networking/browsers/chromium/common.nix b/pkgs/applications/networking/browsers/chromium/common.nix index 8a14225c151..9e174707e40 100644 --- a/pkgs/applications/networking/browsers/chromium/common.nix +++ b/pkgs/applications/networking/browsers/chromium/common.nix @@ -1,6 +1,8 @@ { stdenv, lib, fetchurl, fetchpatch # Channel data: , channel, upstream-info +# Helper functions: +, chromiumVersionAtLeast, versionRange # Native build inputs: , ninja, pkg-config @@ -106,18 +108,6 @@ let buildPath = "out/${buildType}"; libExecPath = "$out/libexec/${packageName}"; - warnObsoleteVersionConditional = min-version: result: - let ungoogled-version = (importJSON ./upstream-info.json).ungoogled-chromium.version; - in warnIf (versionAtLeast ungoogled-version min-version) "chromium: ungoogled version ${ungoogled-version} is newer than a conditional bounded at ${min-version}. You can safely delete it." - result; - chromiumVersionAtLeast = min-version: - let result = versionAtLeast upstream-info.version min-version; - in warnObsoleteVersionConditional min-version result; - versionRange = min-version: upto-version: - let inherit (upstream-info) version; - result = versionAtLeast version min-version && versionOlder version upto-version; - in warnObsoleteVersionConditional upto-version result; - ungoogler = ungoogled-chromium { inherit (upstream-info.deps.ungoogled-patches) rev sha256; }; diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index db11bda740b..86ee33f3510 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -22,15 +22,31 @@ let llvmPackages = llvmPackages_12; stdenv = llvmPackages.stdenv; + upstream-info = (lib.importJSON ./upstream-info.json).${channel}; + + # Helper functions for changes that depend on specific versions: + warnObsoleteVersionConditional = min-version: result: + let ungoogled-version = (lib.importJSON ./upstream-info.json).ungoogled-chromium.version; + in lib.warnIf + (lib.versionAtLeast ungoogled-version min-version) + "chromium: ungoogled version ${ungoogled-version} is newer than a conditional bounded at ${min-version}. You can safely delete it." + result; + chromiumVersionAtLeast = min-version: + let result = lib.versionAtLeast upstream-info.version min-version; + in warnObsoleteVersionConditional min-version result; + versionRange = min-version: upto-version: + let inherit (upstream-info) version; + result = lib.versionAtLeast version min-version && lib.versionOlder version upto-version; + in warnObsoleteVersionConditional upto-version result; + callPackage = newScope chromium; chromium = rec { - inherit stdenv llvmPackages; - - upstream-info = (lib.importJSON ./upstream-info.json).${channel}; + inherit stdenv llvmPackages upstream-info; mkChromiumDerivation = callPackage ./common.nix ({ - inherit channel gnome2 gnomeSupport gnomeKeyringSupport proprietaryCodecs + inherit channel chromiumVersionAtLeast versionRange; + inherit gnome2 gnomeSupport gnomeKeyringSupport proprietaryCodecs cupsSupport pulseSupport ungoogled; gnChromium = gn.overrideAttrs (oldAttrs: { inherit (upstream-info.deps.gn) version; @@ -38,12 +54,14 @@ let inherit (upstream-info.deps.gn) url rev sha256; }; }); - } // lib.optionalAttrs (lib.versionAtLeast upstream-info.version "93") rec { + } // lib.optionalAttrs (chromiumVersionAtLeast "93") rec { llvmPackages = llvmPackages_13; stdenv = llvmPackages.stdenv; }); - browser = callPackage ./browser.nix { inherit channel enableWideVine ungoogled; }; + browser = callPackage ./browser.nix { + inherit channel chromiumVersionAtLeast enableWideVine ungoogled; + }; ungoogled-chromium = callPackage ./ungoogled.nix {}; };