1{ lib
2, buildGoModule
3, fetchFromGitHub
4, installShellFiles
5, git
6, testers
7, d2
8}:
9
10buildGoModule rec {
11 pname = "d2";
12 version = "0.5.1";
13
14 src = fetchFromGitHub {
15 owner = "terrastruct";
16 repo = pname;
17 rev = "v${version}";
18 hash = "sha256-Oq6bJ/cX+kDyVUVP/RpCIcNeWpT3HESUMmR6mEi9X4Q=";
19 };
20
21 vendorHash = "sha256-SocBC/1LrdSQNfcNVa9nnPaq/UvLVIghHlUSJB7ImBk=";
22
23 excludedPackages = [ "./e2etests" ];
24
25 ldflags = [
26 "-s"
27 "-w"
28 "-X oss.terrastruct.com/d2/lib/version.Version=${version}"
29 ];
30
31 nativeBuildInputs = [ installShellFiles ];
32
33 postInstall = ''
34 installManPage ci/release/template/man/d2.1
35 '';
36
37 nativeCheckInputs = [ git ];
38
39 preCheck = ''
40 # See https://github.com/terrastruct/d2/blob/master/docs/CONTRIBUTING.md#running-tests.
41 export TESTDATA_ACCEPT=1
42 '';
43
44 passthru.tests.version = testers.testVersion { package = d2; };
45
46 meta = with lib; {
47 description = "A modern diagram scripting language that turns text to diagrams";
48 homepage = "https://d2lang.com";
49 license = licenses.mpl20;
50 maintainers = with maintainers; [ dit7ya ];
51 };
52}