2014-03-27 07:20:20 +01:00
|
|
|
{ system ? builtins.currentSystem }:
|
|
|
|
|
|
|
|
let
|
2014-03-27 09:40:21 +01:00
|
|
|
inherit (import <nixpkgs> {}) lib writeText stdenv;
|
2014-03-27 07:20:20 +01:00
|
|
|
|
|
|
|
sources = if builtins.pathExists ./sources.nix
|
|
|
|
then import ./sources.nix
|
|
|
|
else null;
|
|
|
|
|
|
|
|
bucketURL = "http://commondatastorage.googleapis.com/"
|
|
|
|
+ "chromium-browser-official";
|
|
|
|
|
2014-03-27 09:40:21 +01:00
|
|
|
debURL = "https://dl.google.com/linux/chrome/deb/pool/main/g";
|
|
|
|
|
|
|
|
# Untrusted mirrors, don't try to update from them!
|
|
|
|
debMirrors = [
|
|
|
|
"http://95.31.35.30/chrome/pool/main/g"
|
|
|
|
"http://mirror.pcbeta.com/google/chrome/deb/pool/main/g"
|
|
|
|
];
|
|
|
|
|
2014-03-27 07:20:20 +01:00
|
|
|
tryChannel = channel: let
|
2014-03-27 09:40:21 +01:00
|
|
|
chan = builtins.getAttr channel sources;
|
2014-03-27 07:20:20 +01:00
|
|
|
in if sources != null then ''
|
2014-03-27 09:40:21 +01:00
|
|
|
oldver="${chan.version}";
|
2014-03-27 07:20:20 +01:00
|
|
|
echo -n "Checking if $oldver ($channel) is up to date..." >&2;
|
|
|
|
if [ "x$(get_newest_ver "$version" "$oldver")" != "x$oldver" ];
|
|
|
|
then
|
|
|
|
echo " no, getting sha256 for new version $version:" >&2;
|
2014-03-27 09:40:21 +01:00
|
|
|
sha256="$(prefetch_sha "$channel" "$version")" || return 1;
|
2014-03-27 07:20:20 +01:00
|
|
|
else
|
|
|
|
echo " yes, keeping old sha256." >&2;
|
2014-03-27 09:40:21 +01:00
|
|
|
sha256="${chan.sha256}";
|
|
|
|
${if (chan ? sha256bin32 && chan ? sha256bin64) then ''
|
|
|
|
sha256="$sha256.${chan.sha256bin32}.${chan.sha256bin64}";
|
|
|
|
'' else ''
|
|
|
|
sha256="$sha256.$(prefetch_deb_sha "$channel" "$version")";
|
|
|
|
''}
|
2014-03-27 07:20:20 +01:00
|
|
|
fi;
|
|
|
|
'' else ''
|
2014-03-27 09:40:21 +01:00
|
|
|
sha256="$(prefetch_sha "$channel" "$version")" || return 1;
|
2014-03-27 07:20:20 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
caseChannel = channel: ''
|
|
|
|
${channel}) ${tryChannel channel};;
|
|
|
|
'';
|
|
|
|
|
|
|
|
in rec {
|
|
|
|
getChannel = channel: let
|
|
|
|
chanAttrs = builtins.getAttr channel sources;
|
|
|
|
in {
|
2014-03-27 09:49:46 +01:00
|
|
|
inherit (chanAttrs) version;
|
|
|
|
|
2014-03-27 09:40:21 +01:00
|
|
|
main = {
|
|
|
|
url = "${bucketURL}/chromium-${chanAttrs.version}.tar.xz";
|
2014-03-27 09:49:46 +01:00
|
|
|
inherit (chanAttrs) sha256;
|
2014-03-27 09:40:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
binary = let
|
|
|
|
pname = if channel == "dev"
|
|
|
|
then "google-chrome-unstable"
|
|
|
|
else "google-chrome-${channel}";
|
|
|
|
arch = if stdenv.is64bit then "amd64" else "i386";
|
|
|
|
relpath = "${pname}/${pname}_${chanAttrs.version}-1_${arch}.deb";
|
|
|
|
in lib.optionalAttrs (chanAttrs ? sha256bin64) {
|
|
|
|
urls = map (url: "${url}/${relpath}") ([ debURL ] ++ debMirrors);
|
|
|
|
sha256 = if stdenv.is64bit
|
|
|
|
then chanAttrs.sha256bin64
|
|
|
|
else chanAttrs.sha256bin32;
|
|
|
|
};
|
2014-03-27 07:20:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
updateHelpers = writeText "update-helpers.sh" ''
|
2014-03-27 09:40:21 +01:00
|
|
|
|
|
|
|
prefetch_main_sha()
|
|
|
|
{
|
|
|
|
nix-prefetch-url "${bucketURL}/chromium-$2.tar.xz";
|
|
|
|
}
|
|
|
|
|
|
|
|
prefetch_deb_sha()
|
|
|
|
{
|
|
|
|
channel="$1";
|
|
|
|
version="$2";
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
dev) pname="google-chrome-unstable";;
|
|
|
|
*) pname="google-chrome-$channel";;
|
|
|
|
esac;
|
|
|
|
|
|
|
|
deb_pre="${debURL}/$pname/$pname";
|
|
|
|
|
|
|
|
deb32=$(nix-prefetch-url "''${deb_pre}_$version-1_i386.deb");
|
|
|
|
deb64=$(nix-prefetch-url "''${deb_pre}_$version-1_amd64.deb");
|
|
|
|
|
|
|
|
echo "$deb32.$deb64";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefetch_sha()
|
|
|
|
{
|
|
|
|
echo "$(prefetch_main_sha "$@").$(prefetch_deb_sha "$@")";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-27 07:20:20 +01:00
|
|
|
get_sha256()
|
|
|
|
{
|
|
|
|
channel="$1";
|
|
|
|
version="$2";
|
|
|
|
|
|
|
|
case "$channel" in
|
|
|
|
${lib.concatMapStrings caseChannel [ "stable" "dev" "beta" ]}
|
|
|
|
esac;
|
|
|
|
|
|
|
|
sha_insert "$version" "$sha256";
|
|
|
|
echo "$sha256";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
}
|