forked from Telefragged/off-the-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
82 lines (74 loc) · 2.55 KB
/
flake.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
{
description = "Ergo grid trading";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, naersk, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
naersk' = pkgs.callPackage naersk {};
in
with pkgs;
{
packages.default =
naersk'.buildPackage {
src = ./cli;
root = ./.;
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
};
devShells.default =
let
escompile =
let
compiler-jar = fetchurl {
url = "https://github.com/ergoplatform/ergoscript-compiler/releases/download/v0.1/ErgoScriptCompiler-assembly-0.1.jar";
sha256 = "1r2bad2q271s0j1mq5yk4c9g13nd7sjwhw9b5fmq2xrw1bdr7xy4";
};
in
writeShellScriptBin "escompile" ''
${jre}/bin/java -cp ${compiler-jar} Compile $@
'';
es2ergotree =
let
xxd = unixtools.xxd;
in
writeShellScriptBin "es2ergotree" ''
if [[ $# -gt 1 ]]; then
echo "es2ergotree: error: too many arguments" >&2
echo "Usage: es2ergotree <script_dir> > output" >&2
exit 1
fi
contract="$1/contract.es"
symbols=$([[ -f "$1/symbols.json" ]] && echo "$1/symbols.json" || echo ""])
output="$(basename "$1").ergotree"
${escompile}/bin/escompile $contract $symbols \
| head -n2 \
| tail -n1 \
| tr -d '\n' \
| ${xxd}/bin/xxd -r -p > $output
'';
rust = pkgs.rust-bin.stable."1.70.0".default.override {
extensions = [ "rust-src" "clippy" ];
};
in
mkShell {
buildInputs = [
openssl
pkg-config
rust
rust-analyzer
escompile
es2ergotree
];
};
}
);
}