-
Notifications
You must be signed in to change notification settings - Fork 1
/
devenv.nix
74 lines (66 loc) · 2.53 KB
/
devenv.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
{
pkgs,
lib,
config,
inputs,
...
}: let
minerd = import ./cpuminer.nix {pkgs = pkgs;};
bitcoind = import ./bitcoind.nix {
pkgs = pkgs;
lib = lib;
};
in {
env.BITCOIND_DATADIR = config.devenv.root + "/.devenv/state/bitcoind";
# https://devenv.sh/packages/
packages =
[bitcoind minerd pkgs.just]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [pkgs.darwin.apple_sdk.frameworks.Security];
# https://devenv.sh/languages/
languages.rust.enable = true;
# https://devenv.sh/processes/
processes = {
run-local-pool.exec = "run-local-pool";
run-job-server.exec = "run-job-server";
run-job-client.exec = "run-job-client";
run-translator-proxy.exec = "run-translator-proxy";
bitcoind-testnet.exec = "bitcoind-testnet";
run-minerd.exec = "run-minerd";
};
# https://devenv.sh/basics/
# https://devenv.sh/services/
# services.postgres.enable = true;
# https://devenv.sh/scripts/
scripts = {
run-local-pool.exec = "cargo -C roles/pool -Z unstable-options run -- -c $DEVENV_ROOT/roles/pool/config-examples/pool-config-local-tp-example.toml";
run-job-server.exec = "cargo -C roles/jd-server -Z unstable-options run -- -c $DEVENV_ROOT/roles/jd-server/config-examples/jds-config-local-example.toml";
run-job-client.exec = "cargo -C roles/jd-client -Z unstable-options run -- -c $DEVENV_ROOT/roles/jd-client/config-examples/jdc-config-local-example.toml";
run-translator-proxy.exec = "cargo -C roles/translator -Z unstable-options run -- -c $DEVENV_ROOT/roles/translator/config-examples/tproxy-config-local-jdc-example.toml";
bitcoind-testnet.exec = "bitcoind -testnet4 -sv2 -sv2port=8442 -debug=sv2 -conf=$DEVENV_ROOT/bitcoin.conf -datadir=$BITCOIND_DATADIR";
run-minerd.exec = "minerd -a sha256d -o stratum+tcp://localhost:34255 -q -D -P";
};
# https://devenv.sh/tasks/
# https://devenv.sh/tests/
# https://devenv.sh/pre-commit-hooks/
# See full reference at https://devenv.sh/reference/options/
tasks."bitcoind:make_datadir" = {
exec = ''mkdir -p $BITCOIND_DATADIR'';
before = ["devenv:enterShell"];
};
pre-commit.hooks = {
alejandra.enable = true;
};
enterShell = ''
echo Just
echo ====
just --list
echo
echo Helper scripts
echo ==============
echo
${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' <<EOF | ${pkgs.util-linuxMinimal}/bin/column -t | ${pkgs.gnused}/bin/sed -e 's|^| |' -e 's|••| |g'
${lib.generators.toKeyValue {} (lib.mapAttrs (name: value: value.description) config.scripts)}
EOF
echo
'';
}