-
Notifications
You must be signed in to change notification settings - Fork 7
/
flake.nix
147 lines (137 loc) · 4.85 KB
/
flake.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
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
146
147
# Author: @googleson78
{
description = "Build dependencies for clc-stackage";
inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
# Follow the nixpkgs from ghc.nix. Rationale:
#
# The glibc that is used to build the custom GHC should be the same as the
# one here, otherwise we will encounter glibc version mismatch errors when
# building packages that depend on glibc (even transitively).
#
# Because ghc.nix is a popular tool for building GHC with nix, it is
# sensible to use the same glibc.
#
# Note this means that this input should generally be upgraded whenever
# ghc.nix is.
ghc_nix = {
url = "git+https://gitlab.haskell.org/ghc/ghc.nix.git";
inputs.flake-compat.follows = "flake-compat";
};
nixpkgs.follows = "ghc_nix/nixpkgs";
# Temporarily include a newer version of nixpkgs so that we can use GHC
# 9.8.2. This newer nixpkgs also contains cabal-install 3.12, which allows
# us to use the new --semaphore option, but unfortunately breaks Agda:
#
# https://github.com/agda/agda/pull/7471
#
# Once we have the Agda fix (version 2.7.0.1), we can use cabal-install
# 3.12.
nixpkgs_new.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, nixpkgs_new, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
};
pkgs_new = import nixpkgs_new {
inherit system;
};
compiler = pkgs_new.haskell.packages.ghc982;
# There are some packages that do not build well with nix:
#
# - grisette: Depends on sbv
#
# - sbv: Builds with the nix-provided GHC in the .#with-ghc shell, but
# fails with a custom built GHC (e.g. building via ghc.nix).
# Possibly due to the combination of Nix + TH + C.
#
# - simple-pango: Strangely this appears to work with a custom GHC but
# not with the one provided by nixpkgs.
# see NOTE: [LD_LIBRARY_PATH]
ldDeps = with pkgs; [
blas # blas-ffi
bzip2 # bnb-staking-csvs
expat # cairo-image
lapack # lapack-ffi
libGL # GLUT, etc.
pcre # regex-pcre
xorg.libX11 # GLFW-b
xorg.libXcursor # GLFW-b
xorg.libXi # GLFW-b
xorg.libXinerama # GLFW-b
xorg.libXrandr # GLFW-b
xorg.libXxf86vm # GLFW-b
zlib # too many to list
];
# The comments indicate haskell packages that require the given
# dependency. This is not exhaustive.
deps = with pkgs; [
cabal-install
curl # curl
fribidi # simple-pango
libdatrie # simple-pango
libGLU # GLURaw
libselinux # simple-pango
libsepol # simple-pango
libthai # simple-pango
libxml2 # c14n
nettle # nettle
openal # OpenAL
pango # simple-pango
pcre2 # simple-cairo
pkg-config
postgresql_16 # postgresql-libpq
systemdMinimal # hidapi requires udev
util-linux # simple-pango requires mount
xorg.libXdmcp # simple-cairo
xz # lzma
] ++ ldDeps;
in
{
devShells.x86_64-linux = {
default = pkgs.mkShell {
buildInputs = deps;
# NOTE: [LD_LIBRARY_PATH]
#
# Deps that also need to be added to LD_LIBRARY_PATH. For instance,
# if we do not add zlib here, we will receive an error like:
#
# libz.so: cannot open shared object file: No such file or directory
#
# Note this is a different error from not including the zlib library
# at all (i.e. forgetting pkgs.zlib).
#
# https://discourse.nixos.org/t/shared-libraries-error-with-cabal-repl-in-nix-shell/8921/9
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath ldDeps}:$LD_LIBRARY_PATH";
# The stack library requires GHC to be on the PATH at build time due
# to TH.
shellHook = ''
#export PATH=/path/to/custom/ghc/stage1/bin/:$PATH
${throw "Remove this line from the flake.nix and add your GHC to the PATH"}
'';
};
dev = pkgs.mkShell {
buildInputs = [
compiler.ghc
compiler.haskell-language-server
compiler.ormolu
pkgs.cabal-install
pkgs.zlib
];
};
# This shell is useless wrt the intended purpose of this repo,
# as the whole point is building stackage w/ a custom GHC. It exists
# primarily to test that there is nothing wrong with the package set
# itself for nix users, as building some of the libs with a custom
# GHC is a challenge on NixOS.
with-ghc = pkgs.mkShell {
buildInputs = deps ++ [ compiler.ghc ];
};
};
};
}