forked from hasktorch/hasktorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
103 lines (86 loc) · 3.14 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
############################################################################
# Hasktorch Nix build
#
# TODO: document top-level attributes and how to build them
#
############################################################################
{ system ? builtins.currentSystem
, crossSystem ? null
# allows to customize ghc and profiling (see ./nix/haskell.nix):
, config ? {}
# allows to override dependencies of the hasktorch project without modifications
, sourcesOverride ? {}
# if true, activates CUDA support
, cudaSupport ? false
# if cudaSupport is true, this needs to be set to a valid CUDA major version number, e.g. 10:
# nix-build --arg cudaSupport true --argstr cudaMajorVersion 10
, cudaMajorVersion ? null
# pinned version of nixpkgs augmented with various overlays.
, pkgs ? import ./nix/default.nix { inherit system crossSystem config sourcesOverride cudaSupport cudaMajorVersion; }
# git sha1 hash, to be passed when not building from a git work tree.
, gitrev ? null
}:
# commonLib includes util.nix and nixpkgs lib.
with pkgs; with commonLib;
let
haskellPackages = recRecurseIntoAttrs
# the Haskell.nix package set, reduced to local packages.
(selectProjectPackages hasktorchHaskellPackages);
libs = collectComponents' "library" haskellPackages;
exes = collectComponents' "exes" haskellPackages;
self = {
# Inherit haskellPackages so that you can still access things that are not exposed below.
inherit haskellPackages;
inherit (haskellPackages.hasktorch.identifier) version;
# `tests` are the test suites which have been built.
tests = collectComponents' "tests" haskellPackages;
# `benchmarks` (only built, not run).
benchmarks = collectComponents' "benchmarks" haskellPackages;
# Grab hasktorch's library components.
inherit (libs)
libtorch-ffi
libtorch-ffi-helper
hasktorch
;
# Grab hasktorch's executable components.
inherit (exes)
codegen
examples
# From /experimental
bounding-box
dataloader-cifar10
hasktorch-gradually-typed
untyped-nlp
;
checks = recurseIntoAttrs {
# `checks.tests` collect results of executing the tests:
tests = collectChecks haskellPackages;
# Example of a linting script used by Buildkite.
# lint-fuzz = callPackage ./nix/check-lint-fuzz.nix {};
};
shell = import ./shell.nix {
inherit pkgs;
withHoogle = true;
};
# Building the stack shell doesn't work in the sandbox. Pass `--option sandbox relaxed` or
# `--option sandbox false` to be able to build this. You have to be root in order to that.
# stackShell = import ./nix/stack-shell.nix {
# inherit pkgs;
# };
# Build the documentation.
combined-haddock = let
haddock-combine = callPackage ./nix/haddock-combine.nix {
runCommand = runCommand;
lib = lib;
ghc = hasktorchHaskellPackages.ghcWithPackages (_: [ ]);
};
in haddock-combine {
hspkgs = builtins.attrValues libs;
prologue = writeTextFile {
name = "prologue";
text = "Documentation for hasktorch and its libraries.";
};
};
};
in
self