forked from cdepillabout/stacklock2nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlay.nix
120 lines (107 loc) · 5.16 KB
/
overlay.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
final: prev: {
# First, call stacklock2nix and pass it the `stack.yaml` for your project.
my-example-haskell-stacklock = final.stacklock2nix {
stackYaml = ../stack.yaml;
# When using `stacklock2nix`, you may need to specify a newer all-cabal-hashes.
#
# This is necessary when you are using a Stackage snapshot/resolver or
# `extraDeps` in your `stack.yaml` file that is _newer_ than the
# `all-cabal-hashes` derivation from the Nixpkgs you are using.
#
# If you are using the latest nixpkgs-unstable and an old Stackage
# resolver, then it is usually not necessary to override
# `all-cabal-hashes`.
#
# If you are using a very recent Stackage resolver and an old Nixpkgs,
# it is almost always necessary to override `all-cabal-hashes`.
#
# WARNING: If you're on a case-insensitive filesystem (like some OSX
# filesystems), you may get a hash mismatch when using fetchFromGitHub
# to fetch all-cabal-hashes. As a workaround in that case, you may
# want to use fetchurl:
#
# ```
# all-cabal-hashes = final.fetchurl {
# url = "https://github.com/commercialhaskell/all-cabal-hashes/archive/f3f41d1f11f40be4a0eb6d9fcc3fe5ff62c0f840.tar.gz";
# sha256 = "sha256-vYFfZ77fOcOQpAef6VGXlAZBzTe3rjBSS2dDWQQSPUw=";
# };
# ```
#
# You can find more information in:
# https://github.com/NixOS/nixpkgs/issues/39308
all-cabal-hashes = final.fetchFromGitHub {
owner = "commercialhaskell";
repo = "all-cabal-hashes";
rev = "f3f41d1f11f40be4a0eb6d9fcc3fe5ff62c0f840";
sha256 = "sha256-MLF0Vv2RHai3n7b04JeUchQortm+ikuwSjAzAHWvZJs=";
};
};
# Then, apply the Haskell package overlays provided by stacklock2nix to the
# Haskell package set you want to use.
#
# This gives you a normal Haskell package set with packages defined by your
# stack.yaml and Stackage snapshot / resolver.
my-example-haskell-pkg-set =
final.haskell.packages.ghc924.override (oldAttrs: {
# Make sure the package set is created with the same all-cabal-hashes you
# passed to `stacklock2nix`.
inherit (final.my-example-haskell-stacklock) all-cabal-hashes;
overrides = final.lib.composeManyExtensions [
# Make sure not to lose any old overrides, although in most cases there
# won't be any.
(oldAttrs.overrides or (_: _: {}))
# An overlay with Haskell packages from the Stackage snapshot.
final.my-example-haskell-stacklock.stackYamlResolverOverlay
# An overlay with `extraDeps` from `stack.yaml`.
final.my-example-haskell-stacklock.stackYamlExtraDepsOverlay
# An overlay with your local packages from `stack.yaml`.
final.my-example-haskell-stacklock.stackYamlLocalPkgsOverlay
# Suggested overrides for common problems.
final.my-example-haskell-stacklock.suggestedOverlay
# Any additional overrides you may want to add.
(hfinal: hprev: {
# The servant-cassava.cabal file is malformed on GitHub:
# https://github.com/haskell-servant/servant-cassava/pull/29
servant-cassava =
final.haskell.lib.compose.overrideCabal
{ editedCabalFile = null; revision = null; }
hprev.servant-cassava;
# The amazon libraries try to access the network in tests,
# so we disable them here.
amazonka = final.haskell.lib.dontCheck hprev.amazonka;
amazonka-core = final.haskell.lib.dontCheck hprev.amazonka-core;
amazonka-sso = final.haskell.lib.dontCheck hprev.amazonka-sso;
amazonka-sts = final.haskell.lib.dontCheck hprev.amazonka-sts;
})
];
});
# Finally, you can pull out the Haskell package you're interested in and
# build it with Nix. This will normally be one of your local packages.
my-example-haskell-app = final.my-example-haskell-pkg-set.my-example-haskell-app;
# You can also easily create a development shell for hacking on your local
# packages with `cabal`.
my-example-haskell-dev-shell =
final.my-example-haskell-pkg-set.shellFor {
packages = haskPkgs: final.my-example-haskell-stacklock.localPkgsSelector haskPkgs;
# Additional packages that should be available for development.
nativeBuildInputs = [
# Some Haskell tools (like cabal-install) can be taken from the
# top-level of Nixpkgs.
final.cabal-install
final.ghcid
final.hpack
final.stack
# Some Haskell tools need to have been compiled with the same compiler
# you used to define your stacklock2nix Haskell package set. Be
# careful not to pull these packages from your stacklock2nix Haskell
# package set, since transitive dependency versions may have been
# carefully setup in Nixpkgs so that the tool will compile, and your
# stacklock2nix Haskell package set will likely contain different
# versions.
final.haskell.packages.ghc924.haskell-language-server
# Other Haskell tools may need to be taken from the stacklock2nix
# Haskell package set, and compiled with the example same dependency
# versions your project depends on.
];
};
}