Skip to content

Commit

Permalink
Merge pull request #200 from basvandijk/simplified-shell.nix
Browse files Browse the repository at this point in the history
Simplified shell.nix
  • Loading branch information
blackgnezdo authored Jul 25, 2018
2 parents e40d2c4 + ff69c12 commit 5be6c2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 47 deletions.
4 changes: 2 additions & 2 deletions nix/src.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "729da53a147eda1a1678a313754fcda3a8791279",
"sha256": "17l19rbhb3wdrrcyjgq34bk3p658jbldzxp9q1scdvrvz0g99psb"
"rev": "7098bcac278a2d028036bb3a23508fd1c52155ac",
"sha256": "04m7z7334mjma0ci3vp4js6rbz4s2jxy864s1v4dkdm7860zjc28"
}
54 changes: 9 additions & 45 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,18 @@

let
# Use pinned packages
_nixpkgs = import <nixpkgs> {};
nixpkgs = _nixpkgs.fetchFromGitHub (_nixpkgs.lib.importJSON ./nix/src.json);
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";
nixpkgs = with (builtins.fromJSON (builtins.readFile ./nix/src.json));
builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
inherit sha256;
};

# 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 ];
};
pkgs = import nixpkgs {};
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 ];
}

0 comments on commit 5be6c2a

Please sign in to comment.