52 lines
1.1 KiB
Nix
52 lines
1.1 KiB
Nix
{ lib
|
|
, buildGoModule
|
|
, makeWrapper
|
|
, symlinkJoin
|
|
, fetchFromGitHub
|
|
, installShellFiles
|
|
, d2plugin-tala
|
|
, withTala ? false
|
|
}:
|
|
|
|
let
|
|
version = "2022-12-12";
|
|
d2 = buildGoModule
|
|
{
|
|
pname = "d2";
|
|
inherit version;
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "terrastruct";
|
|
repo = "d2";
|
|
rev = "a557d1a6edeb18d692c1e1c20c3c0f0cffc2ed21";
|
|
sha256 = "sha256-EzaBURGLnxSX+1FjYQLP7oxov7dGk7xhAnpV8DPzW/g=";
|
|
};
|
|
|
|
vendorSha256 = "sha256-p0os+ap2k5nYWI4+Hf4pwJfHTXaPJldJmf6nznhuRFA=";
|
|
|
|
ldflags = [
|
|
"-s"
|
|
"-w"
|
|
"-X oss.terrastruct.com/d2/lib/version.Version=${version}"
|
|
];
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
patches = [
|
|
../patches/d2/402_preserve_leading_comment_spacing.patch
|
|
];
|
|
|
|
postInstall = "installManPage ci/release/template/man/d2.1";
|
|
|
|
subPackages = [ "." ];
|
|
};
|
|
in
|
|
symlinkJoin {
|
|
name = "d2";
|
|
paths = [ d2 ] ++ lib.optional withTala [ d2plugin-tala ];
|
|
buildInputs = [ makeWrapper ];
|
|
postBuild = ''
|
|
wrapProgram $out/bin/d2 \
|
|
--prefix PATH : "$out/bin"
|
|
'';
|
|
}
|