forked from input-output-hk/marlowe-cardano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
159 lines (149 loc) · 4.88 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
{ system ? builtins.currentSystem
, enableHaskellProfiling ? false
, packages ? import ./. { inherit system enableHaskellProfiling; }
}:
let
inherit (packages) pkgs marlowe marlowe-playground marlowe-dashboard docs webCommon bitte-packages marlowe-cli marlowe-pab plutus-chain-index cardano-wallet dev-scripts;
inherit (dev-scripts) start-cardano-node start-wallet start-chain-index start-marlowe-pab start-dashboard-server;
inherit (pkgs) stdenv lib utillinux python3 nixpkgs-fmt writeShellScriptBin;
inherit (marlowe) haskell stylish-haskell sphinxcontrib-haddock sphinx-markdown-tables sphinxemoji nix-pre-commit-hooks cardano-cli cardano-node;
inherit (marlowe) writeShellScriptBinInRepoRoot;
set-xdg = ''
export XDG_DATA_HOME="''${XDG_DATA_HOME:-''${HOME}/.local/share}"
mkdir -p "''${XDG_DATA_HOME}"
export XDG_RUNTIME_DIR="''${XDG_RUNTIME_DIR:-''${HOME}/.local/run}"
mkdir -p "''${XDG_RUNTIME_DIR}"
'';
start-marlowe-run = writeShellScriptBinInRepoRoot "start-marlowe-run" ''
cd marlowe-dashboard-client
${pkgs.arion}/bin/arion --nix-arg --system --nix-arg x86_64-linux "$@" up --force-recreate
'';
generate-purescript = writeShellScriptBinInRepoRoot "generate-purescript" ''
marlowe-run-generate-purs; marlowe-playground-generate-purs
'';
# For Sphinx, and ad-hoc usage
sphinxTools = python3.withPackages (ps: [
sphinxcontrib-haddock.sphinxcontrib-domaintools
sphinx-markdown-tables
sphinxemoji
ps.sphinxcontrib_plantuml
ps.sphinxcontrib-bibtex
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;
};
hooks = {
inherit (marlowe) dhall-hook purs-tidy-hook;
prettier = {
enable = true;
types_or = [ "javascript" "css" "html" ];
};
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$" ".*/packages.nix$" ];
};
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; [
arion
cacert
editorconfig-core-c
ghcid
jq
nixFlakesAlias
nixpkgs-fmt
nodejs
shellcheck
sqlite-interactive
stack
yq
z3
zlib
nodePackages.prettier
] ++ (lib.optionals (!stdenv.isDarwin) [ rPackages.plotly R ]));
# local build inputs ( -> ./nix/pkgs/default.nix )
localInputs = (with marlowe; [
cabal-install
cardano-node
start-cardano-node
start-wallet
start-chain-index
start-marlowe-pab
start-dashboard-server
cardano-repo-tool
cardano-wallet
fixPngOptimization
fix-prettier
fix-purs-tidy
fix-dhall
fixStylishHaskell
haskell-language-server
haskell-language-server-wrapper
hie-bios
hlint
marlowe-dashboard.build-client
marlowe-dashboard.test-client
marlowe-dashboard.generate-purescript
marlowe-dashboard.start-backend
marlowe-pab
marlowe-playground.build-client
marlowe-playground.generate-purescript
marlowe-playground.start-backend
generate-purescript
plutus-chain-index
stylish-haskell
updateMaterialized
updateClientDeps
docs.build-and-serve-docs
start-marlowe-run
marlowe-cli
cardano-cli
] ++ easyPS.buildInputs);
in
haskell.project.shellFor {
nativeBuildInputs = nixpkgsInputs ++ localInputs ++ [ sphinxTools ];
# 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 $$
''
# Point to some source dependencies
+ ''
export ACTUS_TEST_DATA_DIR=${packages.actus-tests}/tests/
export WEB_COMMON_SRC="${webCommon.cleanSrc}"
'';
}