1{ lib
2, rustPlatform
3, fetchFromGitHub
4, makeWrapper
5, python3
6, which
7, stdenv
8}:
9
10rustPlatform.buildRustPackage rec {
11 pname = "erg";
12 version = "0.6.25";
13
14 src = fetchFromGitHub {
15 owner = "erg-lang";
16 repo = "erg";
17 rev = "v${version}";
18 hash = "sha256-z3481/vWmR5QlULfJZtLdGhwsJKBbLcvyC87SCngMVg=";
19 };
20
21 cargoHash = "sha256-+jN+6At8tLHA/ilSBxugHIS79Cw8bGhE0RUNU4sSGeM=";
22
23 nativeBuildInputs = [
24 makeWrapper
25 python3
26 which
27 ];
28
29 buildFeatures = [ "full" ];
30
31 env = {
32 BUILD_DATE = "1970/01/01 00:00:00";
33 CASE_SENSITIVE = lib.boolToString (!stdenv.isDarwin);
34 GIT_HASH_SHORT = src.rev;
35 };
36
37 # TODO(figsoda): fix tests
38 doCheck = false;
39
40 # the build script is impure and also assumes we are in a git repository
41 postPatch = ''
42 rm crates/erg_common/build.rs
43 '';
44
45 preBuild = ''
46 export HOME=$(mktemp -d)
47 export CARGO_ERG_PATH=$HOME/.erg
48 '';
49
50 postInstall = ''
51 mkdir -p $out/share
52 mv "$CARGO_ERG_PATH" $out/share/erg
53
54 wrapProgram $out/bin/erg \
55 --set-default ERG_PATH $out/share/erg
56 '';
57
58 meta = with lib; {
59 description = "A statically typed language that can deeply improve the Python ecosystem";
60 homepage = "https://github.com/erg-lang/erg";
61 changelog = "https://github.com/erg-lang/erg/releases/tag/${src.rev}";
62 license = with licenses; [ asl20 mit ];
63 maintainers = with maintainers; [ figsoda ];
64 };
65}