gn: get revNum and revShort in src's postFetch

Signed-off-by: Marcin Serwin <marcin@serwin.dev>

+27 -24
+27 -24
pkgs/by-name/gn/gn/package.nix
··· 3 3 lib, 4 4 fetchgit, 5 5 cctools, 6 - writeText, 7 6 ninja, 8 7 python3, 9 8 }: 10 - let 11 - # Note: Please use the recommended version for Chromium stable, i.e. from 12 - # <nixpkgs>/pkgs/applications/networking/browsers/chromium/info.json 13 - rev = "85cc21e94af590a267c1c7a47020d9b420f8a033"; 14 - revNum = "2233"; # git describe $rev --match initial-commit | cut -d- -f3 15 - version = "2025-04-28"; 16 - sha256 = "sha256-+nKP2hBUKIqdNfDz1vGggXSdCuttOt0GwyGUQ3Z1ZHI="; 17 - 18 - revShort = builtins.substring 0 7 rev; 19 - lastCommitPosition = writeText "last_commit_position.h" '' 20 - #ifndef OUT_LAST_COMMIT_POSITION_H_ 21 - #define OUT_LAST_COMMIT_POSITION_H_ 22 9 23 - #define LAST_COMMIT_POSITION_NUM ${revNum} 24 - #define LAST_COMMIT_POSITION "${revNum} (${revShort})" 25 - 26 - #endif // OUT_LAST_COMMIT_POSITION_H_ 27 - ''; 28 - 29 - in 30 10 stdenv.mkDerivation { 31 11 pname = "gn-unstable"; 32 - inherit version; 12 + version = "2025-04-28"; 33 13 34 14 src = fetchgit { 35 15 # Note: The TAR-Archives (+archive/${rev}.tar.gz) are not deterministic! 36 16 url = "https://gn.googlesource.com/gn"; 37 - inherit rev sha256; 17 + # Note: Please use the recommended version for Chromium stable, i.e. from 18 + # <nixpkgs>/pkgs/applications/networking/browsers/chromium/info.json 19 + rev = "85cc21e94af590a267c1c7a47020d9b420f8a033"; 20 + hash = "sha256-SYpWYvGGNLMZPR1LdKKgubbv+4QcxRw8EYp7cNI5wQQ="; 21 + leaveDotGit = true; 22 + deepClone = true; 23 + postFetch = '' 24 + cd "$out" 25 + mkdir .nix-files 26 + git rev-parse --short=12 HEAD > .nix-files/REV_SHORT 27 + git describe --match initial-commit | cut -d- -f3 > .nix-files/REV_NUM 28 + find "$out" -name .git -print0 | xargs -0 rm -rf 29 + ''; 38 30 }; 39 31 40 32 nativeBuildInputs = [ ··· 50 42 # cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security] 51 43 hardeningDisable = [ "format" ]; 52 44 45 + configurePhase = '' 46 + python build/gen.py --no-last-commit-position 47 + cat > out/last_commit_position.h << EOF 48 + #ifndef OUT_LAST_COMMIT_POSITION_H_ 49 + #define OUT_LAST_COMMIT_POSITION_H_ 50 + 51 + #define LAST_COMMIT_POSITION_NUM $(<.nix-files/REV_NUM) 52 + #define LAST_COMMIT_POSITION "$(<.nix-files/REV_NUM) ($(<.nix-files/REV_SHORT))" 53 + 54 + #endif // OUT_LAST_COMMIT_POSITION_H_ 55 + EOF 56 + ''; 57 + 53 58 buildPhase = '' 54 - python build/gen.py --no-last-commit-position 55 - ln -s ${lastCommitPosition} out/last_commit_position.h 56 59 ninja -j $NIX_BUILD_CORES -C out gn 57 60 ''; 58 61