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)
This commit is contained in:
Michael Weiss 2021-08-28 23:12:27 +02:00
parent dae2c39b9e
commit 21edf9c42f
No known key found for this signature in database
GPG Key ID: 5BE487C4D4771D83
3 changed files with 32 additions and 21 deletions

View File

@ -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

View File

@ -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;
};

View File

@ -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 {};
};