From 11e2009821decf55aa20589447076aab5f998464 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 6 Sep 2018 00:11:02 +0900 Subject: [PATCH] haskellPackages.tensorflow-mnist-input-data: fetch Prefetch data so that the package doesn't try to connect to the internet. --- .../configuration-tensorflow.nix | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkgs/development/haskell-modules/configuration-tensorflow.nix b/pkgs/development/haskell-modules/configuration-tensorflow.nix index dfc93686405..d1ca474ba4f 100644 --- a/pkgs/development/haskell-modules/configuration-tensorflow.nix +++ b/pkgs/development/haskell-modules/configuration-tensorflow.nix @@ -62,6 +62,30 @@ in { mkDerivation, base, bytestring, Cabal, cryptonite, directory , filepath, HTTP, network-uri, stdenv }: + + let + urlPrefix = "http://yann.lecun.com/exdb/mnist/"; + + # File names relative to 'urlPrefix' and their sha256. + fileInfos = [ + [ "train-images-idx3-ubyte.gz" + "440fcabf73cc546fa21475e81ea370265605f56be210a4024d2ca8f203523609" + ] + + [ "train-labels-idx1-ubyte.gz" + "3552534a0a558bbed6aed32b30c495cca23d567ec52cac8be1a0730e8010255c" + ] + + [ "t10k-images-idx3-ubyte.gz" + "8d422c7b0a1c1c79245a5bcf07fe86e33eeafee792b84584aec276f5a2dbc4e6" + ] + + [ "t10k-labels-idx1-ubyte.gz" + "f7ae60f92e00ec6debd23a6088c31dbd2371eca3ffa0defaefb259924204aec6" + ] + ]; + downloads = map (x: pkgs.fetchurl { url = urlPrefix + builtins.head x; sha256= builtins.tail x;}) fileInfos; + in mkDerivation { pname = "tensorflow-mnist-input-data"; version = "0.1.0.0"; @@ -71,6 +95,9 @@ in base bytestring Cabal cryptonite directory filepath HTTP network-uri ]; + preConfigure = pkgs.lib.strings.concatStringsSep "\n" ( + map (x: "cp ${x} data/$(stripHash ${x})") downloads + ); libraryHaskellDepends = [ base ]; homepage = "https://github.com/tensorflow/haskell#readme"; description = "Downloader of input data for training MNIST";