d2: add self-referencing connections patch

This commit is contained in:
Dmitriy Pleshevskiy 2022-11-30 15:28:47 +03:00
parent e3555cf2cb
commit 911e92f3e1
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
4 changed files with 32 additions and 38 deletions

View file

@ -13,7 +13,7 @@
final: prev:
final.setAttrByPath [ name ] (mkPackage name prev);
allPackageNames = [ "d2" "d2_unstable" ];
allPackageNames = [ "d2" ];
mkAllPackages = pkgs':
listToAttrs
(map

View file

@ -0,0 +1,25 @@
diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go
index 7bc2ba1..750eb17 100644
--- a/d2graph/d2graph.go
+++ b/d2graph/d2graph.go
@@ -710,20 +710,16 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label
return nil, errors.New("cannot connect to reserved keyword")
}
}
}
src := srcObj.EnsureChild(srcID)
dst := dstObj.EnsureChild(dstID)
- if src == dst {
- return nil, errors.New("self-referencing connection")
- }
-
edge := &Edge{
Attributes: Attributes{
Label: Scalar{
Value: label,
},
},
Src: src,
SrcArrow: srcArrow,

View file

@ -4,7 +4,7 @@
, installShellFiles
}:
let version = "0.0.13"; in
let version = "2022-11-30"; in
buildGoModule {
pname = "d2";
@ -13,11 +13,11 @@ buildGoModule {
src = fetchFromGitHub {
owner = "terrastruct";
repo = "d2";
rev = "v${version}";
sha256 = "sha256-2abGQmgwqxWFk7NScdgfEjRYZF2rw8kxTKRwcl2LRg0=";
rev = "e6c7d066164040098d294c00779a2248c402c864";
sha256 = "sha256-Qlm5i7l4/ZdVulXVOyry3cwZp7bIDbCXUZ5PngpD9bM=";
};
vendorSha256 = "sha256-/BEl4UqOL4Ux7I2eubNH2YGGl4DxntpI5WN9ggvYu80=";
vendorSha256 = "sha256-yNaocc1iaOHlLqDLql+3XWL9j0RoxBXSWATi7QCNgJI=";
ldflags = [
"-s"
@ -27,6 +27,8 @@ buildGoModule {
nativeBuildInputs = [ installShellFiles ];
patches = [ ../patches/d2/self_referencing_connections.patch ];
postInstall = "installManPage ci/release/template/man/d2.1";
subPackages = [ "cmd/d2" ];

View file

@ -1,33 +0,0 @@
{ lib
, buildGoModule
, fetchFromGitHub
, installShellFiles
}:
let version = "2022-11-30"; in
buildGoModule {
pname = "d2";
inherit version;
src = fetchFromGitHub {
owner = "terrastruct";
repo = "d2";
rev = "e6c7d066164040098d294c00779a2248c402c864";
sha256 = "sha256-Qlm5i7l4/ZdVulXVOyry3cwZp7bIDbCXUZ5PngpD9bM=";
};
vendorSha256 = "sha256-yNaocc1iaOHlLqDLql+3XWL9j0RoxBXSWATi7QCNgJI=";
ldflags = [
"-s"
"-w"
"-X oss.terrastruct.com/d2/lib/version.Version=${version}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall = "installManPage ci/release/template/man/d2.1";
subPackages = [ "cmd/d2" ];
}