1
1
{ stdenv , lib , fetchpatch
2
- , recompressTarball
2
+ , zstd
3
+ , fetchFromGitiles
4
+ , fetchNpmDeps
3
5
, buildPackages
4
6
, buildPlatform
5
7
, pkgsBuildBuild
6
- , pkgsBuildTarget
7
8
# Channel data:
8
- , channel , upstream-info
9
+ , upstream-info
9
10
# Helper functions:
10
11
, chromiumVersionAtLeast , versionRange
11
12
12
13
# Native build inputs:
13
14
, ninja , pkg-config
14
15
, python3 , perl
16
+ , nodejs
17
+ , npmHooks
15
18
, which
16
- , llvmPackages_attrName
17
19
, libuuid
18
20
, overrideCC
19
21
# postPatch:
126
128
# https://github.com/NixOS/nixpkgs/issues/142901
127
129
buildPlatformLlvmStdenv =
128
130
let
129
- llvmPackages = pkgsBuildBuild . ${ llvmPackages_attrName } ;
131
+ llvmPackages = pkgsBuildBuild . rustc . llvmPackages ;
130
132
in
131
133
overrideCC llvmPackages . stdenv
132
134
( llvmPackages . stdenv . cc . override {
@@ -148,19 +150,74 @@ let
148
150
else throw "no chromium Rosetta Stone entry for os: ${ platform . config } " ;
149
151
} ;
150
152
153
+ isElectron = packageName == "electron" ;
154
+
155
+ chromiumDeps = lib . mapAttrs ( path : args : fetchFromGitiles ( removeAttrs args [ "recompress" ] // lib . optionalAttrs args . recompress or false {
156
+ name = "source.tar.zstd" ;
157
+ downloadToTemp = false ;
158
+ passthru . unpack = true ;
159
+ postFetch = ''
160
+ tar \
161
+ --use-compress-program="${ lib . getExe zstd } -T$NIX_BUILD_CORES" \
162
+ --sort=name \
163
+ --mtime="1970-01-01" \
164
+ --owner=root --group=root \
165
+ --numeric-owner --mode=go=rX,u+rw,a-s \
166
+ --remove-files \
167
+ --directory="$out" \
168
+ -cf "$TMPDIR/source.zstd" .
169
+ mv "$TMPDIR/source.zstd" "$out"
170
+ '' ;
171
+ } ) ) upstream-info . DEPS ;
172
+
173
+ unpackPhaseSnippet = lib . concatStrings ( lib . mapAttrsToList ( path : dep :
174
+ ( if dep . unpack or false
175
+ then ''
176
+ mkdir -p ${ path }
177
+ pushd ${ path }
178
+ unpackFile ${ dep }
179
+ popd
180
+ ''
181
+ else ''
182
+ mkdir -p ${ builtins . dirOf path }
183
+ cp -r ${ dep } /. ${ path }
184
+ ''
185
+ ) + ''
186
+ chmod u+w -R ${ path }
187
+ '' ) chromiumDeps ) ;
188
+
151
189
base = rec {
152
190
pname = "${ lib . optionalString ungoogled "ungoogled-" } ${ packageName } -unwrapped" ;
153
191
inherit ( upstream-info ) version ;
154
192
inherit packageName buildType buildPath ;
155
193
156
- src = recompressTarball { inherit version ; inherit ( upstream-info ) hash ; } ;
194
+ unpackPhase = ''
195
+ runHook preUnpack
196
+
197
+ ${ unpackPhaseSnippet }
198
+ sourceRoot=src
199
+
200
+ runHook postUnpack
201
+ '' ;
202
+
203
+ npmRoot = "third_party/node" ;
204
+ npmDeps = ( fetchNpmDeps {
205
+ src = chromiumDeps . "src" ;
206
+ sourceRoot = npmRoot ;
207
+ hash = upstream-info . deps . npmHash ;
208
+ } ) . overrideAttrs ( p : {
209
+ nativeBuildInputs = p . nativeBuildInputs or [ ] ++ [ zstd ] ;
210
+ } ) ;
157
211
158
212
nativeBuildInputs = [
159
213
ninja pkg-config
160
214
python3WithPackages perl
161
215
which
162
- buildPackages . ${ llvmPackages_attrName } . bintools
216
+ buildPackages . rustc . llvmPackages . bintools
163
217
bison gperf
218
+ ] ++ lib . optionals ( ! isElectron ) [
219
+ nodejs
220
+ npmHooks . npmConfigHook
164
221
] ;
165
222
166
223
depsBuildBuild = [
295
352
} )
296
353
] ;
297
354
298
- postPatch = ''
355
+ postPatch = lib . optionalString ( ! isElectron ) ''
356
+ ln -s ${ ./files/gclient_args.gni } build/config/gclient_args.gni
357
+
358
+ echo 'LASTCHANGE=${ upstream-info . DEPS . "src" . rev } -refs/tags/${ version } @{#0}' > build/util/LASTCHANGE
359
+ echo "$SOURCE_DATE_EPOCH" > build/util/LASTCHANGE.committime
360
+
361
+ cat << EOF > gpu/config/gpu_lists_version.h
362
+ /* Generated by lastchange.py, do not edit.*/
363
+ #ifndef GPU_CONFIG_GPU_LISTS_VERSION_H_
364
+ #define GPU_CONFIG_GPU_LISTS_VERSION_H_
365
+ #define GPU_LISTS_VERSION "${ upstream-info . DEPS . "src" . rev } "
366
+ #endif // GPU_CONFIG_GPU_LISTS_VERSION_H_
367
+ EOF
368
+
369
+ cat << EOF > skia/ext/skia_commit_hash.h
370
+ /* Generated by lastchange.py, do not edit.*/
371
+ #ifndef SKIA_EXT_SKIA_COMMIT_HASH_H_
372
+ #define SKIA_EXT_SKIA_COMMIT_HASH_H_
373
+ #define SKIA_COMMIT_HASH "${ upstream-info . DEPS . "src/third_party/skia" . rev } -"
374
+ #endif // SKIA_EXT_SKIA_COMMIT_HASH_H_
375
+ EOF
376
+
377
+ echo -n '${ upstream-info . DEPS . "src/third_party/dawn" . rev } ' > gpu/webgpu/DAWN_VERSION
378
+
379
+ mkdir -p third_party/jdk/current/bin
380
+ '' + ''
299
381
# Workaround/fix for https://bugs.chromium.org/p/chromium/issues/detail?id=1313361:
300
382
substituteInPlace BUILD.gn \
301
383
--replace '"//infra/orchestrator:orchestrator_all",' ""
384
466
llvmCcAndBintools = symlinkJoin {
385
467
name = "llvmCcAndBintools" ;
386
468
paths = [
387
- pkgsBuildTarget . ${ llvmPackages_attrName } . llvm
388
- pkgsBuildTarget . ${ llvmPackages_attrName } . stdenv . cc
469
+ buildPackages . rustc . llvmPackages . llvm
470
+ buildPackages . rustc . llvmPackages . stdenv . cc
389
471
] ;
390
472
} ;
391
473
490
572
# enable those features in our stable builds.
491
573
preConfigure = ''
492
574
export RUSTC_BOOTSTRAP=1
575
+ '' + lib . optionalString ( ! isElectron ) ''
576
+ (
577
+ cd third_party/node
578
+ grep patch update_npm_deps | sh
579
+ )
493
580
'' ;
494
581
495
582
configurePhase = ''
547
634
'' ;
548
635
549
636
passthru = {
550
- updateScript = ./update.py ;
551
- chromiumDeps = {
552
- gn = gnChromium ;
553
- } ;
554
- inherit recompressTarball ;
637
+ updateScript = ./update.mjs ;
638
+ } // lib . optionalAttrs ( ! isElectron ) {
639
+ inherit chromiumDeps npmDeps ;
555
640
} ;
556
641
}
557
642
# overwrite `version` with the exact same `version` from the same source,
0 commit comments