Created
November 2, 2017 00:35
-
-
Save bencoman/4ac2f48906152d6528df1db4feb006c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
with stdenv.lib; | |
let | |
mkGnFlags = | |
let | |
# Serialize Nix types into GN types according to this document: | |
# https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/language.md | |
mkGnString = value: "\"${escape ["\"" "$" "\\"] value}\""; | |
sanitize = value: | |
if value == true then "true" | |
else if value == false then "false" | |
else if isList value then "[${concatMapStringsSep ", " sanitize value}]" | |
else if isInt value then toString value | |
else if isString value then mkGnString value | |
else throw "Unsupported type for GN value `${value}'."; | |
toFlag = key: value: "${key}=${sanitize value}"; | |
in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs)); | |
gnFlags = mkGnFlags ({ | |
linux_use_bundled_binutils = false; | |
use_gold = true; | |
gold_path = "${stdenv.cc}/bin"; | |
is_debug = false; | |
use_sysroot = false; | |
treat_warnings_as_errors = false; | |
is_clang = false; | |
clang_use_chrome_plugins = false; | |
remove_webcore_debug_symbols = true; | |
use_gtk3 = true; | |
enable_swiftshader = false; | |
fieldtrial_testing_like_official_build = true; | |
# Google API keys, see: | |
# http://www.chromium.org/developers/how-tos/api-keys | |
# Note: These are for NixOS/nixpkgs use ONLY. For your own distribution, | |
# please get your own set of keys. | |
google_api_key = "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI"; | |
google_default_client_id = "404761575300.apps.googleusercontent.com"; | |
google_default_client_secret = "9rIFQjfnkykEmqb6FfjJQD1D"; | |
}); | |
gnSystemLibraries = [ | |
"flac" "libwebp" "libxslt" "yasm" "opus" "snappy" "libpng" "zlib" | |
]; | |
# build paths and release info | |
packageName = "pdfium"; # extraAttrs.packageName or extraAttrs.name; | |
buildType = "Release"; | |
buildPath = "out/${buildType}"; | |
libExecPath = "$out/libexec/${packageName}"; | |
base = rec { | |
name = "pdfium.99.9"; | |
configurePhase = '' | |
runHook preConfigure | |
# Build gn | |
#python tools/gn/bootstrap/bootstrap.py -v -s --no-clean | |
#PATH="$PWD/out/Release:$PATH" | |
# This is to ensure expansion of $out. | |
libExecPath="${libExecPath}" | |
python build/linux/unbundle/replace_gn_files.py \ | |
--system-libraries ${toString gnSystemLibraries} | |
gn gen --args=${gnFlags} out/Release | |
runHook postConfigure | |
''; | |
buildInputs = [ | |
stdenv | |
ninja | |
which | |
nodejs | |
#fetchurl | |
gnutar | |
# default dependencies | |
bzip2 flac speex libopus | |
libevent expat libjpeg snappy | |
libpng libcap | |
xdg_utils yasm minizip libwebp | |
libusb1 pciutils nss re2 zlib libvpx | |
# python2Packages | |
perl | |
pkgconfig | |
bison | |
gperf | |
glib gtk2 gtk3 dbus_glib | |
protobuf speechd cups | |
ffmpeg harfbuzz harfbuzz-icu libxslt libxml2 | |
]; | |
src = pkgs.fetchgit { | |
"url" = "https://pdfium.googlesource.com/pdfium"; | |
"rev" = "effa1b15ae2ab34ae15892787d5c1caa015bd2d4"; | |
"sha256" = "1w667clbn2akvwrjx965jm1qw3ffhinmlkk22mp21drjssqbm8aa"; | |
"fetchSubmodules" = true; | |
leaveDotGit = true; | |
}; | |
buildCommand = '' | |
cd ~/Repos/pdfium/build/pdfium* | |
echo BEGINNING BUILD | |
''; | |
# outputs = ["out" ]; | |
# | |
}; | |
in stdenv.mkDerivation (base) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Half way through trying to build pdfium under NixOS.