diff --git a/flake.nix b/flake.nix index dcd107a..26963b1 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,7 @@ final: prev: final.setAttrByPath [ name ] (mkPackage name prev); - allPackageNames = [ "d2" "d2_unstable" ]; + allPackageNames = [ "d2" ]; mkAllPackages = pkgs': listToAttrs (map diff --git a/patches/d2/self_referencing_connections.patch b/patches/d2/self_referencing_connections.patch new file mode 100644 index 0000000..c4b3428 --- /dev/null +++ b/patches/d2/self_referencing_connections.patch @@ -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, diff --git a/pkgs/d2.nix b/pkgs/d2.nix index d7e16c8..4636f68 100644 --- a/pkgs/d2.nix +++ b/pkgs/d2.nix @@ -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" ]; diff --git a/pkgs/d2_unstable.nix b/pkgs/d2_unstable.nix deleted file mode 100644 index 00aa82b..0000000 --- a/pkgs/d2_unstable.nix +++ /dev/null @@ -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" ]; -}