<commit_before>{ stdenv, lib, fetchgit, fetchzip, fetchpatch, darwin
, git, ninja, python }:

stdenv.mkDerivation rec {
  name = "gn-${version}";
  version = "20180830";

  src = fetchgit {
    url = "https://gn.googlesource.com/gn";
    rev = "106b823805adcc043b2bfe5bc21d58f160a28a7b";
    leaveDotGit = true;  # gen.py uses "git describe" to generate last_commit_position.h
    deepClone = true;
    sha256 = "00xl7rfcwyig23q6qnqzv13lvzm3n30di242zcz2m9rdlfspiayb";
  };

  postPatch = ''
    # FIXME Needed with old Apple SDKs
    substituteInPlace base/mac/foundation_util.mm \
      --replace "NSArray<NSString*>*" "NSArray*"
  '';

  nativeBuildInputs = [ ninja python git ];
  buildInputs = lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
    libobjc
    cctools

    # frameworks
    ApplicationServices
    Foundation
    AppKit
  ]);

  buildPhase = ''
    python build/gen.py --no-sysroot
    ninja -j $NIX_BUILD_CORES -C out gn
  '';

  installPhase = ''
    install -vD out/gn "$out/bin/gn"
  '';

  meta = with lib; {
    description = "A meta-build system that generates NinjaBuild files";
    homepage = https://gn.googlesource.com/gn;
    license = licenses.bsd3;
    platforms = platforms.unix;
    maintainers = with maintainers; [ <NAME> ];
  };
}<commit_msg>gn: generate last_commit_position.h without git<commit_after>{ stdenv, lib, fetchgit, fetchzip, fetchpatch, darwin, writeText
, git, ninja, python }:

let
  rev = "106b823805adcc043b2bfe5bc21d58f160a28a7b";
  sha256 = "1a5s6i07s8l4f1bakh3fyaym00xz7zgd49sp6awm10xb7yjh95ba";

  shortRev = builtins.substring 0 7 rev;
  lastCommitPosition = writeText "last_commit_position.h" ''
    #ifndef OUT_LAST_COMMIT_POSITION_H_
    #define OUT_LAST_COMMIT_POSITION_H_

    #define LAST_COMMIT_POSITION "(${shortRev})"

    #endif  // OUT_LAST_COMMIT_POSITION_H_
  '';

in
stdenv.mkDerivation rec {
  name = "gn-${version}";
  version = "20180830";

  src = fetchgit {
    url = "https://gn.googlesource.com/gn";
    inherit rev sha256;
  };

  postPatch = ''
    # FIXME Needed with old Apple SDKs
    substituteInPlace base/mac/foundation_util.mm \
      --replace "NSArray<NSString*>*" "NSArray*"
  '';

  nativeBuildInputs = [ ninja python git ];
  buildInputs = lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
    libobjc
    cctools

    # frameworks
    ApplicationServices
    Foundation
    AppKit
  ]);

  buildPhase = ''
    python build/gen.py --no-sysroot --no-last-commit-position
    ln -s ${lastCommitPosition} out/last_commit_position.h
    ninja -j $NIX_BUILD_CORES -C out gn
  '';

  installPhase = ''
    install -vD out/gn "$out/bin/gn"
  '';

  meta = with lib; {
    description = "A meta-build system that generates NinjaBuild files";
    homepage = https://gn.googlesource.com/gn;
    license = licenses.bsd3;
    platforms = platforms.unix;
    maintainers = with maintainers; [ <NAME> ];
  };
}
{'fraction_non_alphanumeric': 0.11674608577263444, 'fraction_numerical': 0.038461538461538464, 'mean_word_length': 3.3670133729569094, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2490437', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1067, 'n_words': 221}