Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions pkgs/applications/networking/browsers/chromium/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,7 @@ let
pulseSupport
ungoogled
;
gnChromium = buildPackages.gn.overrideAttrs (oldAttrs: {
version = if (upstream-info.deps.gn ? "version") then upstream-info.deps.gn.version else "0";
src = fetchgit {
url = "https://gn.googlesource.com/gn";
inherit (upstream-info.deps.gn) rev hash;
};
});
gnChromium = buildPackages.gn.override upstream-info.deps.gn;
});

browser = callPackage ./browser.nix {
Expand Down
6 changes: 4 additions & 2 deletions pkgs/applications/networking/browsers/chromium/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"hash": "sha256-UouvzNFStYScnyfIJcz1Om7cDhC7EyShZQ/Icu73BPo="
},
"gn": {
"version": "0-unstable-2025-06-19",
"rev": "97b68a0bb62b7528bc3491c7949d6804223c2b82",
"hash": "sha256-m+z10s40Q/iYcoMw3o/+tmhIdqHMsYJjdGabHrK/aqo="
"hash": "sha256-gwptzuirIdPAV9XCaAT09aM/fY7d6xgBU7oSu9C4tmE="
},
"npmHash": "sha256-R2gOpfPOUAmnsnUTIvzDPHuHNzL/b2fwlyyfTrywEcI="
},
Expand Down Expand Up @@ -809,8 +810,9 @@
"hash": "sha256-UouvzNFStYScnyfIJcz1Om7cDhC7EyShZQ/Icu73BPo="
},
"gn": {
"version": "0-unstable-2025-06-19",
"rev": "97b68a0bb62b7528bc3491c7949d6804223c2b82",
"hash": "sha256-m+z10s40Q/iYcoMw3o/+tmhIdqHMsYJjdGabHrK/aqo="
"hash": "sha256-gwptzuirIdPAV9XCaAT09aM/fY7d6xgBU7oSu9C4tmE="
},
"ungoogled-patches": {
"rev": "139.0.7258.66-1",
Expand Down
39 changes: 28 additions & 11 deletions pkgs/applications/networking/browsers/chromium/update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ for (const attr_path of Object.keys(lockfile)) {
chromedriver: !ungoogled ? await fetch_chromedriver_binaries(await get_latest_chromium_release('mac')) : undefined,
deps: {
depot_tools: {},
gn: {},
gn: await fetch_gn(chromium_rev, lockfile_initial[attr_path].deps.gn),
'ungoogled-patches': !ungoogled ? undefined : {
rev: ungoogled_patches.rev,
hash: ungoogled_patches.hash,
Expand All @@ -78,12 +78,6 @@ for (const attr_path of Object.keys(lockfile)) {
hash: depot_tools.hash,
}

const gn = await fetch_gn(chromium_rev, lockfile_initial[attr_path].deps.gn)
lockfile[attr_path].deps.gn = {
rev: gn.rev,
hash: gn.hash,
}

// DEPS update loop
lockfile[attr_path].DEPS = await resolve_DEPS(depot_tools.out, chromium_rev)
for (const [path, value] of Object.entries(lockfile[attr_path].DEPS)) {
Expand Down Expand Up @@ -133,10 +127,34 @@ for (const attr_path of Object.keys(lockfile)) {

async function fetch_gn(chromium_rev, gn_previous) {
const DEPS_file = await get_gitiles_file('https://chromium.googlesource.com/chromium/src', chromium_rev, 'DEPS')
const gn_rev = /^\s+'gn_version': 'git_revision:(?<rev>.+)',$/m.exec(DEPS_file).groups.rev
const hash = gn_rev === gn_previous.rev ? gn_previous.hash : ''
const { rev } = /^\s+'gn_version': 'git_revision:(?<rev>.+)',$/m.exec(DEPS_file).groups

const cache_hit = rev === gn_previous.rev;
if (cache_hit) {
return gn_previous
}

const commit_date = await get_gitiles_commit_date('https://gn.googlesource.com/gn', rev)
const version = `0-unstable-${commit_date}`

return await prefetch_gitiles('https://gn.googlesource.com/gn', gn_rev, hash)
const expr = [`(import ./. {}).gn.override { version = "${version}"; rev = "${rev}"; hash = ""; }`]
const derivation = await $nixpkgs`nix-instantiate --expr ${expr}`

return {
version,
rev,
hash: await prefetch_FOD(derivation),
}
}


async function get_gitiles_commit_date(base_url, rev) {
const url = `${base_url}/+/${rev}?format=json`
const response = await (await fetch(url)).text()
const json = JSON.parse(response.replace(`)]}'\n`, ''))

const date = new Date(json.commiter.time)
return date.toISOString().split("T")[0]
}


Expand Down Expand Up @@ -259,4 +277,3 @@ async function prefetch_FOD(...args) {

return hash
}

79 changes: 0 additions & 79 deletions pkgs/by-name/gn/gn/generic.nix

This file was deleted.

104 changes: 98 additions & 6 deletions pkgs/by-name/gn/gn/package.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,102 @@
{ callPackage, ... }@args:
{
stdenv,
lib,
fetchgit,
cctools,
ninja,
python3,

callPackage ./generic.nix args {
# Note: Please use the recommended version for Chromium stable, i.e. from
# <nixpkgs>/pkgs/applications/networking/browsers/chromium/info.json
rev = "85cc21e94af590a267c1c7a47020d9b420f8a033";
revNum = "2233"; # git describe $rev --match initial-commit | cut -d- -f3
version = "2025-04-28";
sha256 = "sha256-+nKP2hBUKIqdNfDz1vGggXSdCuttOt0GwyGUQ3Z1ZHI=";
version ?
# This is a workaround for update-source-version to be able to update this
let
_version = "0-unstable-2025-06-19";
in
_version,
rev ? "97b68a0bb62b7528bc3491c7949d6804223c2b82",
hash ? "sha256-gwptzuirIdPAV9XCaAT09aM/fY7d6xgBU7oSu9C4tmE=",
}:

stdenv.mkDerivation {
pname = "gn";
inherit version;

src = fetchgit {
url = "https://gn.googlesource.com/gn";
inherit rev hash;
leaveDotGit = true;
deepClone = true;
postFetch = ''
cd "$out"
mkdir .nix-files
git rev-parse --short=12 HEAD > .nix-files/REV_SHORT
git describe --match initial-commit | cut -d- -f3 > .nix-files/REV_NUM
find "$out" -name .git -print0 | xargs -0 rm -rf
'';
};

nativeBuildInputs = [
ninja
python3
];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
cctools
];

env.NIX_CFLAGS_COMPILE = "-Wno-error";
# Relax hardening as otherwise gn unstable 2024-06-06 and later fail with:
# cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
hardeningDisable = [ "format" ];

configurePhase = ''
runHook preConfigure

python build/gen.py --no-last-commit-position
cat > out/last_commit_position.h << EOF
#ifndef OUT_LAST_COMMIT_POSITION_H_
#define OUT_LAST_COMMIT_POSITION_H_

#define LAST_COMMIT_POSITION_NUM $(<.nix-files/REV_NUM)
#define LAST_COMMIT_POSITION "$(<.nix-files/REV_NUM) ($(<.nix-files/REV_SHORT))"

#endif // OUT_LAST_COMMIT_POSITION_H_
EOF

runHook postConfigure
'';

buildPhase = ''
runHook preBuild

ninja -v -j $NIX_BUILD_CORES -C out gn

runHook postBuild
'';

installPhase = ''
runHook preInstall

install -vD out/gn "$out/bin/gn"

runHook postInstall
'';

setupHook = ./setup-hook.sh;

passthru.updateScript = ./update.sh;

meta = {
description = "Meta-build system that generates build files for Ninja";
mainProgram = "gn";
homepage = "https://gn.googlesource.com/gn";
license = lib.licenses.bsd3;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [
stesie
matthewbauer
marcin-serwin
emilylange
];
};
}
21 changes: 21 additions & 0 deletions pkgs/by-name/gn/gn/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p jq curl common-updater-scripts

set -ex

rev=$(
curl --location "https://raw.githubusercontent.com/NixOS/nixpkgs/refs/heads/master/pkgs/applications/networking/browsers/chromium/info.json" \
| jq -r ".chromium.deps.gn.rev"
)

commit_time=$(
curl "https://gn.googlesource.com/gn/+/$rev?format=json" \
| sed "s/)]}'//" \
| jq -r ".committer.time" \
| awk '{print $2, $3, $5, $4 $6}'
)

commit_date=$(TZ= date --date "$commit_time" --iso-8601)
version="0-unstable-$commit_date"

update-source-version --rev="$rev" --version-key="_version" "gn" "$version"
15 changes: 6 additions & 9 deletions pkgs/development/tools/electron/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"chromium": {
"deps": {
"gn": {
"hash": "sha256-EqbwCLkseND1v3UqM+49N7GuoXJ3PlJjWOes4OijQ3U=",
"hash": "sha256-U0f/Q134UJrSke+/o9Hs4+mQa/vSM2hdkRXhLfhnqME=",
"rev": "ed1abc107815210dc66ec439542bee2f6cbabc00",
"url": "https://gn.googlesource.com/gn",
"version": "2025-01-13"
"version": "0-unstable-2025-01-13"
}
},
"version": "134.0.6998.205"
Expand Down Expand Up @@ -1313,10 +1312,9 @@
"chromium": {
"deps": {
"gn": {
"hash": "sha256-vDKMt23RMDI+KX6CmjfeOhRv2haf/mDOuHpWKnlODcg=",
"hash": "sha256-MnGl+D9ahQibUHCtyOUf1snvmeupUn4D2yrDj55JTe4=",
"rev": "6e8e0d6d4a151ab2ed9b4a35366e630c55888444",
"url": "https://gn.googlesource.com/gn",
"version": "2025-03-24"
"version": "0-unstable-2025-03-24"
}
},
"version": "136.0.7103.177"
Expand Down Expand Up @@ -2638,10 +2636,9 @@
"chromium": {
"deps": {
"gn": {
"hash": "sha256-UB9a7Fr1W0yYld6WbXyRR8dFqWsj/zx4KumDZ5JQKSM=",
"hash": "sha256-BplU8qNKObVrKMLKTyqivPF1L6bbJulFC+Zop9UpmZY=",
"rev": "ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b",
"url": "https://gn.googlesource.com/gn",
"version": "2025-05-21"
"version": "0-unstable-2025-05-21"
}
},
"version": "138.0.7204.185"
Expand Down
Loading
Loading