# 使用 Homebrew, dnf, MacPorts, Nix, pacman, zypper, scoop, winget 安装 d2

查看 d2 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:d2
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install d2
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install d2
```

  证据: MacPorts ports tree: graphics/d2/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- dnf (92%):

```sh
sudo dnf install d2
```

  证据: Fedora Rawhide package metadata: d2 from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst

- Nix (92%):

```sh
nix profile install nixpkgs#d2
```

  证据: nixpkgs package indexes: pkgs/by-name/d2/d2/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

- pacman (92%):

```sh
sudo pacman -S d2
```

  证据: Arch Linux sync databases: d2 from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- zypper (92%):

```sh
sudo zypper install d2
```

  证据: openSUSE Tumbleweed package metadata: d2 from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

### Windows

- Scoop (92%):

```sh
scoop install main/d2
```

  证据: Scoop official bucket manifest trees: bucket/d2.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

- winget (92%):

```sh
winget install --id Terrastruct.D2 -e
```

  证据: Windows Package Manager source index: Terrastruct.D2 from https://cdn.winget.microsoft.com/cache/source.msix

## 软件包事实

- **软件包键:** brew:d2
- **软件包管理器:** Homebrew
- **版本:** 0.7.1
- **来源摘要:** Modern diagram scripting language that turns text to diagrams
- **主页:** <https://d2lang.com/>
- **仓库:** <https://github.com/terrastruct/d2>
- **最后更新:** 2026-08-01T19:58:36-07:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- d2 (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 0.7.1
## 项目历史与用法

D2 is a modern diagram scripting language and CLI that turns text files into diagrams, especially for software architecture and documentation workflows.

### 项目历史

The D2 repository was created in 2022 by Terrastruct. The README presents D2 as a language, command-line renderer, and Go library, with official documentation, a playground, themes, language tooling, plugins, and export formats.

### 采用历史

D2 entered the diagram-as-code ecosystem as another text-to-diagram option alongside tools such as Graphviz and Mermaid. Its README emphasizes package-manager installation, editor/tooling support, and a list of open-source projects that document with D2.

### 使用方式

The usual workflow is to write a .d2 file and run the d2 CLI to produce SVG, PNG, or PDF output. D2 can also be used as a Go library and can swap layout engines such as ELK or TALA.

### 为什么软件包爱好者会关心

D2 is package-manager friendly because it ships as a single CLI for docs pipelines: install it with a system package manager, keep diagrams as source text, and regenerate images in builds or documentation sites.

### 时间线

- 2022: D2 repository created.
- 2022: Early v0.1.x tags published.
- 2025: v0.7.1 release published.

### Related projects

- D2 relates to diagram-as-code tools, Graphviz-style layout engines, ELK, TALA, Go documentation pipelines, and editor plugins.

### 来源

- <https://github.com/terrastruct/d2>
- <https://api.github.com/repos/terrastruct/d2>
- <https://github.com/terrastruct/d2/releases/tag/v0.7.1>
- <https://d2lang.com/>


## 安全说明

generalized runtime or code generation signal.

- **Geiger 风险:** yellow / 中
- generalized runtime or code generation signal

## 其他软件包管理器记录

- Nix - d2: normalized package name match | nixpkgs package indexes: pkgs/by-name/d2/d2/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- dnf - d2 - 0.6.9-8.fc44: normalized package name match | Fedora Rawhide package metadata: d2 from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | Modern diagram scripting language that turns text to diagrams | https://github.com/terrastruct/d2
- pacman - d2 - 0.7.1-2: normalized package name match | Arch Linux sync databases: d2 from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | A modern diagram scripting language that turns text to diagrams | https://d2lang.com
- zypper - d2 - 0.7.1-1.7: normalized package name match | openSUSE Tumbleweed package metadata: d2 from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | CLI tool and modern declarative language that turns text to diagrams | https://github.com/terrastruct/d2
- MacPorts - d2: normalized package name match | MacPorts ports tree: graphics/d2/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Scoop - main/d2: normalized package name match | Scoop official bucket manifest trees: bucket/d2.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1
- winget - Terrastruct.D2: normalized package name match | Windows Package Manager source index: Terrastruct.D2 from https://cdn.winget.microsoft.com/cache/source.msix


## Combined YAML source

View the package source record on GitHub. [combined/d2.yml](https://github.com/mxcl/pkgdb/blob/main/combined/d2.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
