-
Notifications
You must be signed in to change notification settings - Fork 6
/
default.nix
73 lines (62 loc) · 2.79 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
let
# Some constant configuration that's factored separately.
#
config = import ./config.nix;
# For reproducibility we'll use this project's pinned Nixpkgs instead of
# `(import <nixpkgs> {})`. This way we get a specific version of Nixpkgs
# instead of a version that happens to be in the environment's `NIX_PATH`.
#
external = import ../../nix/external;
nixpkgs = (import external.nixpkgs-unstable) {
# We don't want user configuration affecting this build. This is
# recommended boilerplate when importing Nixpkgs.
config = {}; # to avoid picking up ~/.config/nixpkgs/config.nix
overlays = []; # to avoid picking up ~/.config/nixpkgs/overlays
};
# This is the build of HLS for this project.
#
hls = import ../.. {
ghcVersion = config.hlsGhcVersion;
hlsUnstable = config.hlsUnstable;
};
# This builds all the executables provided by a Stack project and puts them
# into a single Nix package derivation. We can use this not only to build with
# Nix, but also with `nix-shell` to get a shell environment with `PATH` set up
# with HLS, Stack, and GHC. The GHC instance won't be loaded with packages of
# any dependencies. Instead of Nix, Stack manage Haskell dependencies.
#
in nixpkgs.haskell.lib.buildStackProject {
# This name is just for Nix metadata.
name = "example-haskell-stack";
# buildStackProject has explicit configuration for the GHC instance.
#
ghc = nixpkgs.haskell.compiler.${config.nixpkgsGhcVersion};
# buildStackProject also has explicit configuration for the Stack instance.
# To allow Stack invocations and HLS invocations to work within the
# nix-shell this wrapper script disable's Stack's built-in Nix integration
# forcibly (even if we're on NixOS). Additionally we tell Stack not to
# manage getting a GHC instance. Nix sets up all needed build tools and
# non-Haskell dependencies.
#
stack = hls.stack-nonix;
# These are extra tools beyond GHC and Stack that we want on our PATH in our
# Nix shell.
#
nativeBuildInputs = # nixpkgs.lib.optionals nixpkgs.lib.inNixShell [
[
hls.hls-renamed
hls.hls-wrapper
hls.implicit-hie
];
# Here we specify non-Haskell dependencies. They are not automatically
# detected/guessed, and we must list them out explicitly.
#
# buildInputs = [nixpkgs.icu67];
buildInputs = hls.stackNixPackages ./stack.yaml nixpkgs;
# It's recommended to always filter source to just what's needed. This way,
# any intermediate files created while developing don't affect Nix hash
# calculations, which could result in cache misses against /nix/store.
#
src = nixpkgs.lib.sourceFilesBySuffices ./.
[".hs" ".lhs" ".cabal" ".yaml"]; #".lock"];
}