forked from Ali-Hill/plutus-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
176 lines (166 loc) · 5.37 KB
/
shell.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
{ system ? builtins.currentSystem
, enableHaskellProfiling ? false
, sourcesOverride ? { }
, sources ? import ./nix/sources.nix { inherit system; } // sourcesOverride
, packages ? import ./. { inherit system enableHaskellProfiling sources sourcesOverride; }
}:
let
inherit (packages) pkgs plutus-apps docs webCommon;
inherit (pkgs) stdenv lib utillinux python3 nixpkgs-fmt glibcLocales;
inherit (plutus-apps) haskell stylish-haskell sphinxcontrib-haddock sphinx-markdown-tables sphinxemoji scriv nix-pre-commit-hooks cabal-fmt;
# Feed cardano-wallet, cardano-cli & cardano-node to our shell. This is stable as it doesn't mix
# dependencies with this code-base; the fetched binaries are the "standard" builds that people
# test. This should be fast as it mostly fetches Hydra caches without building much.
cardano-wallet = (import sources.flake-compat {
inherit pkgs;
src = builtins.fetchTree
{
type = "github";
owner = "input-output-hk";
repo = "cardano-wallet";
rev = "18a931648550246695c790578d4a55ee2f10463e";
narHash = "sha256-3Rnj/g3KLzOW5YSieqsUa9IF1Td22Eskk5KuVsOFgEQ=";
};
}).defaultNix;
cardano-node = import
(pkgs.fetchgit {
url = "https://github.com/input-output-hk/cardano-node";
# A standard release compatible with the cardano-wallet commit above is always preferred.
rev = "1.35.4";
sha256 = "1j01m2cp2vdcl26zx9xmipr551v3b2rz9kfn9ik8byfwj1z7652r";
})
{ };
# For Sphinx, scriv, and ad-hoc usage
pythonTools = python3.withPackages (ps: [
scriv
sphinxcontrib-haddock.sphinxcontrib-domaintools
sphinx-markdown-tables
sphinxemoji
ps.sphinxcontrib_plantuml
ps.sphinxcontrib-bibtex
ps.sphinx-autobuild
ps.sphinx
ps.sphinx_rtd_theme
ps.recommonmark
]);
# Configure project pre-commit hooks
pre-commit-check = nix-pre-commit-hooks.run {
src = (lib.cleanSource ./.);
tools = {
stylish-haskell = stylish-haskell;
nixpkgs-fmt = nixpkgs-fmt;
shellcheck = pkgs.shellcheck;
cabal-fmt = cabal-fmt;
};
hooks = {
purs-tidy-hook = {
enable = true;
name = "purs-tidy";
entry = "${plutus-apps.purs-tidy}/bin/purs-tidy format-in-place";
files = "\\.purs$";
language = "system";
};
stylish-haskell.enable = true;
nixpkgs-fmt = {
enable = true;
# While nixpkgs-fmt does exclude patterns specified in `.ignore` this
# does not appear to work inside the hook. For now we have to thus
# maintain excludes here *and* in `./.ignore` and *keep them in sync*.
excludes = [ ".*nix/pkgs/haskell/materialized.*/.*" ".*/spago-packages.nix$" ];
};
cabal-fmt.enable = true;
shellcheck.enable = true;
png-optimization = {
enable = true;
name = "png-optimization";
description = "Ensure that PNG files are optimized";
entry = "${pkgs.optipng}/bin/optipng";
files = "\\.png$";
};
};
};
nixFlakesAlias = pkgs.runCommand "nix-flakes-alias" { } ''
mkdir -p $out/bin
ln -sv ${pkgs.nixFlakes}/bin/nix $out/bin/nix-flakes
'';
# build inputs from nixpkgs ( -> ./nix/default.nix )
nixpkgsInputs = with pkgs; [
awscli2
bzip2
cacert
editorconfig-core-c
dateutils
ghcid
jq
nixFlakesAlias
nixpkgs-fmt
cabal-fmt
nodejs
plantuml
# See https://github.com/cachix/pre-commit-hooks.nix/issues/148 for why we need this
pre-commit
shellcheck
sqlite-interactive
stack
wget
yq
z3
zlib
];
# local build inputs ( -> ./nix/pkgs/default.nix )
localInputs = (with plutus-apps; [
cabal-install
cardano-node.cardano-cli
cardano-node.cardano-node
cardano-wallet.packages.${pkgs.system}.cardano-wallet
cardano-repo-tool
docs.build-and-serve-docs
fixPngOptimization
fix-purs-tidy
fixCabalFmt
fixStylishHaskell
haskell-language-server
haskell-language-server-wrapper
hie-bios
hlint
psa
purescript-language-server
purs-0_14_3
purs-tidy
spago
spago2nix
stylish-haskell
updateClientDeps
]);
in
haskell.project.shellFor {
nativeBuildInputs = nixpkgsInputs ++ localInputs ++ [ pythonTools ];
# We don't currently use this, and it's a pain to materialize, and otherwise
# costs a fair bit of eval time.
withHoogle = false;
shellHook = ''
${pre-commit-check.shellHook}
''
# Work around https://github.com/NixOS/nix/issues/3345, which makes
# tests etc. run single-threaded in a nix-shell.
# Sets the affinity to cores 0-1000 for $$ (current PID in bash)
# Only necessary for linux - darwin doesn't even expose thread
# affinity APIs!
+ lib.optionalString stdenv.isLinux ''
${utillinux}/bin/taskset -pc 0-1000 $$
''
+ ''
export GITHUB_SHA=$(git rev-parse HEAD)
export WEB_COMMON_SRC=${webCommon.cleanSrc}
# This is probably set by haskell.nix's shellFor, but it interferes
# with the pythonTools in nativeBuildInputs above.
# This workaround will become obsolete soon once this respository
# is migrated to Standard.
export PYTHONPATH=
'';
# This is no longer set automatically as of more recent `haskell.nix` revisions,
# but is useful for users with LANG settings.
LOCALE_ARCHIVE = lib.optionalString
(stdenv.hostPlatform.libc == "glibc")
"${glibcLocales}/lib/locale/locale-archive";
}