summaryrefslogtreecommitdiff
path: root/pkgs/development/compilers/vyper/default.nix
blob: 72ebb1d2e4cae0289fd75529f923c5a0fca30f8f (plain)
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
{
  lib,
  lark,
  asttokens,
  buildPythonPackage,
  cbor2,
  fetchPypi,
  git,
  immutables,
  importlib-metadata,
  packaging,
  pycryptodome,
  recommonmark,
  setuptools-scm,
  sphinx,
  sphinx-rtd-theme,
  writeText,
}:

let
  sample-contract = writeText "example.vy" ''
    count: int128

    @deploy
    def __init__(foo: address):
        self.count = 1
  '';

in
buildPythonPackage rec {
  pname = "vyper";
  version = "0.4.3";
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-IqdXNldAHYo7xpDWXWt3QWgABxgJeMOgX5iS2zHV3PU=";
  };

  postPatch = ''
    # pythonRelaxDeps doesn't work
    substituteInPlace setup.py \
      --replace-fail "setuptools_scm>=7.1.0,<8.0.0" "setuptools_scm>=7.1.0"
  '';

  nativeBuildInputs = [
    # Git is used in setup.py to compute version information during building
    # ever since https://github.com/vyperlang/vyper/pull/2816
    git

    setuptools-scm
  ];

  pythonRelaxDeps = [
    "asttokens"
    "packaging"
  ];

  propagatedBuildInputs = [
    lark
    asttokens
    cbor2
    immutables
    importlib-metadata
    packaging
    pycryptodome

    # docs
    recommonmark
    sphinx
    sphinx-rtd-theme
  ];

  checkPhase = ''
    $out/bin/vyper "${sample-contract}"
  '';

  pythonImportsCheck = [
    "vyper"
  ];

  meta = {
    description = "Pythonic Smart Contract Language for the EVM";
    homepage = "https://github.com/vyperlang/vyper";
    changelog = "https://github.com/vyperlang/vyper/releases/tag/v${version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ siraben ];
  };
}