-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
363 additions
and
45 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Main where | ||
|
||
import HasktorchSkeleton | ||
|
||
main :: IO () | ||
main = putStrLn "Hello Hasktorch!" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
inputs = { | ||
haskell-nix.url = "github:input-output-hk/haskell.nix"; | ||
stackageSrc = { | ||
url = "github:input-output-hk/stackage.nix"; | ||
flake = false; | ||
}; | ||
hackageSrc = { | ||
url = "github:input-output-hk/hackage.nix"; | ||
flake = false; | ||
}; | ||
utils.url = "github:numtide/flake-utils"; | ||
libtorch-nix = { | ||
url = "github:hasktorch/libtorch-nix/d14b0fd10b96d192b92b8ccc7254ade4b3489331"; | ||
flake = false; | ||
}; | ||
}; | ||
|
||
outputs = inputs@{ self, nixpkgs, haskell-nix, utils, ... }: | ||
let | ||
name = "hasktorchSkeleton"; | ||
compiler = "ghc8104"; # Not used for `stack.yaml` based projects. | ||
cudaSupport = false; | ||
cudaMajorVersion = null; | ||
project-name = "${name}HaskellPackages"; | ||
|
||
|
||
# This overlay adds our project to pkgs | ||
project-overlay = final: prev: { | ||
${project-name} = | ||
#assert compiler == supported-compilers; | ||
final.haskell-nix.project' { | ||
# 'cleanGit' cleans a source directory based on the files known by git | ||
src = prev.haskell-nix.haskellLib.cleanGit { | ||
inherit name; | ||
src = ./.; | ||
}; | ||
|
||
compiler-nix-name = compiler; | ||
projectFileName = "cabal.project"; # Not used for `stack.yaml` based projects. | ||
modules = [ | ||
# Fixes for libtorch-ffi | ||
{ | ||
packages.libtorch-ffi = { | ||
configureFlags = with final; [ | ||
"--extra-lib-dirs=${torch}/lib" | ||
"--extra-include-dirs=${torch}/include" | ||
"--extra-include-dirs=${torch}/include/torch/csrc/api/include" | ||
]; | ||
flags = { | ||
cuda = cudaSupport; | ||
gcc = !cudaSupport && final.stdenv.hostPlatform.isDarwin; | ||
}; | ||
}; | ||
} | ||
]; | ||
|
||
}; | ||
|
||
}; | ||
in | ||
{ overlay = final: prev: { | ||
"${name}" = ("${project-name}-overlay" final prev)."${project-name}".flake {}; | ||
}; | ||
} // (utils.lib.eachSystem [ "x86_64-linux" ] (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ | ||
haskell-nix.overlay | ||
(final: prev: { | ||
haskell-nix = prev.haskell-nix // { | ||
sources = prev.haskell-nix.sources // { | ||
hackage = inputs.hackageSrc; | ||
stackage = inputs.stackageSrc; | ||
}; | ||
modules = [ | ||
# Fixes for libtorch-ffi | ||
{ | ||
packages.libtorch-ffi = { | ||
configureFlags = with final; [ | ||
"--extra-lib-dirs=${torch}/lib" | ||
"--extra-include-dirs=${torch}/include" | ||
"--extra-include-dirs=${torch}/include/torch/csrc/api/include" | ||
]; | ||
flags = { | ||
cuda = cudaSupport; | ||
gcc = !cudaSupport && final.stdenv.hostPlatform.isDarwin; | ||
}; | ||
}; | ||
} | ||
]; | ||
}; | ||
}) | ||
(import ./nix/overlays/libtorch.nix { inherit inputs cudaSupport cudaMajorVersion; }) | ||
project-overlay | ||
]; | ||
}; | ||
flake = pkgs."${project-name}".flake {}; | ||
in flake // rec { | ||
|
||
packages.example = flake.packages."${name}:exe:example"; | ||
|
||
defaultPackage = packages.example; | ||
|
||
devShell = (import ./shell.nix { | ||
inherit cudaSupport cudaMajorVersion pkgs; | ||
withHoogle = false; | ||
}); | ||
} | ||
)); | ||
} |
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
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
Oops, something went wrong.