-
Notifications
You must be signed in to change notification settings - Fork 28
/
default.nix
197 lines (179 loc) · 6.45 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{ config ? {}
, system ? builtins.currentSystem
, crossSystem ? null
, sourcesOverride ? {}
# Set application for getting a specific application nixkgs-src.json
, application ? ""
# Override nixpkgs-src.json to a file in your repo
, nixpkgsOverride ? ""
, nixpkgsJsonOverride ? ""
# Modify nixpkgs with overlays
, nixpkgsOverlays ? []
, defaultSources ? import ./nix/sources.nix { pkgs = pkgsDefault; }
, pkgsDefault ? import defaultSources.nixpkgs { inherit config system crossSystem; }
}:
let
upstreamedDeprecation = p: __trace "WARNING: commonLib.${p} is deprecated. Please use it from nixpkgs directly instead.";
fetchTarballFromJson = jsonFile:
let
spec = builtins.fromJSON (builtins.readFile jsonFile);
in builtins.fetchTarball {
url = "${spec.url}/archive/${spec.rev}.tar.gz";
inherit (spec) sha256;
};
deprecationWarning = parameter: builtins.trace ''
WARNING: iohk-nix \"${parameter}\" parameter is deprecated.
Please use niv (https://github.com/nmattia/niv/) and the \"sourcesOverride\" parameter instead.
'';
sources = defaultSources // sourcesOverride;
commonLib = rec {
fetchNixpkgs = throw "Please use niv to pin nixpkgs instead.";
# equivalent of <nixpkgs> but pinned instead of system
inherit (sources) nixpkgs;
inherit pkgsDefault;
getPkgs = let
system' = system;
config' = config;
crossSystem' = crossSystem;
in { args ? {}
, extraOverlays ? nixpkgsOverlays
, system ? system'
, config ? config'
, crossSystem ? crossSystem' }: import nixpkgs ({
config = config;
overlays = extraOverlays;
inherit system crossSystem;
} // args);
getPkgsDefault = let
system' = system;
config' = config;
crossSystem' = crossSystem;
in { args ? {}
, system ? system'
, config ? config'
, crossSystem ? crossSystem' }: import nixpkgs ({
inherit system crossSystem config;
} // args);
pkgs = getPkgs {};
getPackages = pkgs.callPackage ./get-packages.nix {};
maybeEnv = import ./maybe-env.nix;
commitIdFromGitRepo = upstreamedDeprecation "commitIdFromGitRepo" pkgs.lib.commitIdFromGitRepo;
# A variant of lib.commitIdFromGitRepo which provides a default rev, instead of
# throwing an exception in cases of error.
# Example usage: commitIdFromGitRepoOrZero ./.git
commitIdFromGitRepoOrZero = path:
let
zero = "0000000000000000000000000000000000000000";
res = builtins.tryEval (pkgs.lib.commitIdFromGitRepo path);
in
if builtins.pathExists path
then (if res.success then res.value else zero)
else zero;
# Development tools
inherit (haskell-nix-extra-packages) stack-hpc-coveralls hpc-coveralls;
hlint = upstreamedDeprecation "hlint" pkgsDefault.hlint;
openapi-spec-validator = upstreamedDeprecation "openapi-spec-validator" pkgsDefault.python3Packages.openapi-spec-validator;
inherit (import sources.cardano-repo-tool {inherit system;}) cardano-repo-tool;
stack-cabal-sync-shell = pkgsDefault.callPackage ./pkgs/stack-cabal-sync-shell.nix { inherit cardano-repo-tool; };
supervisord = pkgsDefault.callPackage ./supervisord {};
fixStylishHaskell = pkgsDefault.callPackage ./tests/fix-stylish-haskell.nix {};
# Check scripts
check-hydra = __trace "check-hydra is deprecated. Please use hydraEvalErrors" pkgsDefault.callPackage ./ci/check-hydra.nix {};
checkStackProject = pkgsDefault.callPackage ./ci/check-stack-project.nix {};
hydraEvalErrors = pkgsDefault.callPackage ./ci/hydra-eval-errors {};
checkRepoTagsOnMasterBranches = pkgsDefault.callPackage ./ci/check-source-repo-tags-on-master.nix {};
inherit (pkgsDefault.callPackage ./ci/cabal-project-regenerate {}) cabalProjectRegenerate checkCabalProject;
};
cardanoLib = commonLib.pkgsDefault.callPackage ./cardano-lib {};
jormungandrLib = commonLib.pkgsDefault.callPackage ./jormungandr-lib { inherit rust-packages; };
tests = {
hlint = ./tests/hlint.nix;
shellcheck = ./tests/shellcheck.nix;
stylish-haskell = ./tests/stylish-haskell.nix;
};
overlays = {
rust-packages = rust-packages.overlays;
haskell-nix-extra = [(import ./overlays/haskell-nix-extra)];
crypto = [(import ./overlays/crypto)];
iohkNix = [(pkgs: super: rec {
iohkNix = import ./. {
inherit (pkgs) config system;
pkgsDefault = pkgs;
};
iohk-nix.lib = import ./lib pkgs.lib;
})];
utils = [(import ./overlays/utils)];
};
rust-packages = rec {
overlays = [
(commonLib.pkgsDefault.callPackage ./overlays/rust/mozilla.nix {})
(import ./overlays/rust)
];
pkgs = import sources."nixpkgs-19.09" {
inherit overlays config system crossSystem;
};
};
# This attribute is here for iohk-nix/release.nix Hydra builds.
# Projects should generally use the haskell-nix-extra overlay directly.
haskell-nix-extra-packages = let
baseOverlays = overlays;
baseConfig = config;
haskellNix = (import defaultSources."haskell.nix" {
inherit system sourcesOverride;
}).nixpkgsArgs;
in rec {
overlays = haskellNix.overlays ++ baseOverlays.haskell-nix-extra;
config = haskellNix.config // baseConfig;
pkgs = import defaultSources.nixpkgs {
inherit overlays config system crossSystem;
};
inherit (pkgs) stackNixRegenerate haskellBuildUtils;
} // pkgsDefault.lib.genAttrs
[ "stack-hpc-coveralls" "hpc-coveralls" ]
(pkg: throw "ERROR: iohk-nix `haskell-nix-extra-packages.${pkg}` has been removed.");
shell = import ./shell.nix;
self = {
inherit
overlays
sources
shell
tests
rust-packages
haskell-nix-extra-packages
cardanoLib
jormungandrLib;
inherit (pkgsDefault)
niv;
inherit (commonLib)
# package sets
nixpkgs
pkgs
pkgsDefault
# library functions
fetchNixpkgs
getPkgs
getPkgsDefault
getPackages
maybeEnv
commitIdFromGitRepo
commitIdFromGitRepoOrZero
cabalProjectRegenerate
supervisord
# packages
stack-hpc-coveralls
hpc-coveralls
hlint
stylish-haskell
openapi-spec-validator
cardano-repo-tool
stack-cabal-sync-shell
# scripts
check-hydra
checkCabalProject
hydraEvalErrors
checkRepoTagsOnMasterBranches
checkStackProject
fixStylishHaskell;
release-lib = ./lib/release-lib.nix;
};
in self