mirror of
https://github.com/tensorflow/haskell.git
synced 2024-11-23 03:19:44 +01:00
Merge pull request #200 from basvandijk/simplified-shell.nix
Simplified shell.nix
This commit is contained in:
commit
5be6c2ab5a
2 changed files with 12 additions and 48 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "729da53a147eda1a1678a313754fcda3a8791279",
|
||||
"sha256": "17l19rbhb3wdrrcyjgq34bk3p658jbldzxp9q1scdvrvz0g99psb"
|
||||
"rev": "7098bcac278a2d028036bb3a23508fd1c52155ac",
|
||||
"sha256": "04m7z7334mjma0ci3vp4js6rbz4s2jxy864s1v4dkdm7860zjc28"
|
||||
}
|
||||
|
|
56
shell.nix
56
shell.nix
|
@ -2,54 +2,18 @@
|
|||
|
||||
let
|
||||
# Use pinned packages
|
||||
_nixpkgs = import <nixpkgs> {};
|
||||
nixpkgs = _nixpkgs.fetchFromGitHub (_nixpkgs.lib.importJSON ./nix/src.json);
|
||||
nixpkgs = with (builtins.fromJSON (builtins.readFile ./nix/src.json));
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
pkgs = import nixpkgs {};
|
||||
|
||||
# Either use specified GHC or use GHC 8.2.2 (which we need for LTS 11.9)
|
||||
myghc = if isNull ghc then pkgs.haskell.compiler.ghc822 else ghc;
|
||||
|
||||
# Fetch tensorflow library
|
||||
tensorflow-c = pkgs.stdenv.mkDerivation {
|
||||
name = "tensorflow-c";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.8.0.tar.gz";
|
||||
sha256 = "0qzy15rc3x961cyi3bqnygrcnw4x69r28xkwhpwrv1r0gi6k73ha";
|
||||
};
|
||||
|
||||
# Patch library to use our libc, libstdc++ and others
|
||||
buildCommand = ''
|
||||
. $stdenv/setup
|
||||
mkdir -pv $out
|
||||
tar -C $out -xzf $src
|
||||
chmod +w $out/lib/libtensorflow.so
|
||||
${pkgs.patchelf}/bin/patchelf --set-rpath "${pkgs.stdenv.cc.libc}/lib:${pkgs.stdenv.cc.cc.lib}/lib" $out/lib/libtensorflow.so
|
||||
chmod -w $out/lib/libtensorflow.so
|
||||
'';
|
||||
};
|
||||
|
||||
# Wrapped stack executable that uses the nix-provided GHC
|
||||
stack = pkgs.stdenv.mkDerivation {
|
||||
name = "stack-system-ghc";
|
||||
builder = pkgs.writeScript "stack" ''
|
||||
source $stdenv/setup
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \
|
||||
--add-flags --system-ghc
|
||||
'';
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
};
|
||||
in
|
||||
pkgs.haskell.lib.buildStackProject {
|
||||
ghc = myghc;
|
||||
stack = stack;
|
||||
# Either use specified GHC or use GHC 8.2.2 (which we need for LTS 11.9)
|
||||
ghc = if isNull ghc then pkgs.haskell.compiler.ghc822 else ghc;
|
||||
extraArgs = "--system-ghc";
|
||||
name = "tf-env";
|
||||
buildInputs =
|
||||
[
|
||||
pkgs.snappy
|
||||
pkgs.zlib
|
||||
pkgs.protobuf3_3
|
||||
tensorflow-c
|
||||
stack
|
||||
];
|
||||
buildInputs = with pkgs; [ snappy zlib protobuf libtensorflow ];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue