forked from diku-dk/futhark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
145 lines (124 loc) · 4.95 KB
/
default.nix
File metadata and controls
145 lines (124 loc) · 4.95 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# This default.nix builds a tarball containing a statically linked
# Futhark binary and some manpages. Likely to only work on linux.
#
# Just run 'nix-build' and fish the tarball out of 'result/'.
#
# For the Haskell dependencies that diverge from our pinned Nixpkgs,
# we use cabal2nix like thus:
#
# $ cabal2nix cabal://sexp-grammar-2.2.1 > nix/sexp-grammar.nix
#
# And then import them into the configuration.
#
# Also remember this guide: https://github.com/Gabriel439/haskell-nix/blob/master/project1/README.md
{ compiler ? "ghc883", # ignored ATM
suffix ? "nightly",
commit ? "" }:
let
config = {
packageOverrides = pkgs: rec {
haskellPackages = pkgs.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: rec {
aeson =
haskellPackagesNew.aeson_2_0_2_0;
time-compat =
haskellPackagesNew.time-compat_1_9_6_1;
semialign =
haskellPackagesNew.semialign_1_2_0_1;
hashable =
haskellPackagesNew.hashable_1_4_0_1;
OneTuple =
haskellPackagesNew.OneTuple_0_3_1;
# Need to disable the test suite as otherwise we have a
# circular dependency with quickcheck-instances.
text-short =
pkgs.haskell.lib.dontCheck haskellPackagesNew.text-short_0_1_4;
quickcheck-instances =
haskellPackagesNew.quickcheck-instances_0_3_27;
hashable-time =
haskellPackagesNew.hashable-time_0_3;
futhark-data =
haskellPackagesNew.callPackage ./nix/futhark-data.nix { };
futhark-server =
haskellPackagesNew.callPackage ./nix/futhark-server.nix { };
futhark-manifest =
haskellPackagesNew.callPackage ./nix/futhark-manifest.nix { };
futhark =
# callCabal2Nix does not do a great job at determining
# which files must be included as source, which causes
# trouble if you have lots of other large files lying
# around (say, data files for testing). As a workaround
# we explicitly tell it which files are needed. This must
# be _manually_ kept in sync with whatever the cabal file requires.
let sources = ["futhark.cabal"
"Setup.hs"
"LICENSE"
"^src.*"
"^rts.*"
"^docs.*"
"^prelude.*"
"^assets.*"
"^unittests.*"
];
cleanSource = src: pkgs.lib.sourceByRegex src sources;
in
pkgs.haskell.lib.overrideCabal
(pkgs.haskell.lib.addBuildTools
(haskellPackagesNew.callCabal2nix "futhark" (cleanSource ./.) { })
[ pkgs.python39Packages.sphinx ])
( _drv: {
isLibrary = false;
isExecutable = true;
enableSharedExecutables = false;
enableSharedLibraries = false;
enableLibraryProfiling = false;
configureFlags = [
"--ghc-option=-optl=-static"
"--ghc-option=-split-sections"
"--extra-lib-dirs=${pkgs.ncurses.override { enableStatic = true; }}/lib"
"--extra-lib-dirs=${pkgs.glibc.static}/lib"
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
];
preBuild = ''
if [ "${commit}" ]; then echo "${commit}" > commit-id; fi
'';
postBuild = (_drv.postBuild or "") + ''
make -C docs man
'';
postInstall = (_drv.postInstall or "") + ''
mkdir -p $out/share/man/man1
cp docs/_build/man/*.1 $out/share/man/man1/
mkdir -p $out/share/futhark/
cp LICENSE $out/share/futhark/
'';
}
);
};
};
};
};
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs { inherit config; };
futhark = pkgs.haskellPackages.futhark;
in pkgs.stdenv.mkDerivation rec {
name = "futhark-" + suffix;
version = futhark.version;
src = tools/release;
buildInputs = [ futhark ];
buildPhase = ''
cp -r skeleton futhark-${suffix}
cp -r ${futhark}/bin futhark-${suffix}/bin
mkdir -p futhark-${suffix}/share
cp -r ${futhark}/share/man futhark-${suffix}/share/
chmod +w -R futhark-${suffix}
cp ${futhark}/share/futhark/LICENSE futhark-${suffix}/
[ "${commit}" ] && echo "${commit}" > futhark-${suffix}/commit-id
tar -Jcf futhark-${suffix}.tar.xz futhark-${suffix}
'';
installPhase = ''
mkdir -p $out
cp futhark-${suffix}.tar.xz $out/futhark-${suffix}.tar.xz
'';
}