prelude-install
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInstall & configure Prelude
安装与配置Prelude
Prelude is a devshell UI suite — a flake-parts module, or
for any other flake: a welcome banner (MOTD),
an interactive command picker (), a Markdown docs viewer, and a themed
Starship prompt. Everything runs from the published flake — no checkout of
the Prelude repo is needed. Print docs without cloning:
prelude.lib.evalModulenix developxsh
nix run github:darkmatter/prelude#skill -- install # full consumer walkthrough
nix run github:darkmatter/prelude#skill -- options # generated prelude.* referencePrelude是一套devshell UI套件——可作为flake-parts模块使用,也可通过适配其他任意flake:包含欢迎横幅(MOTD)、交互式命令选择器()、Markdown文档查看器,以及带主题的Starship提示符。所有功能都基于发布的flake运行——无需检出Prelude仓库。无需克隆即可查看文档:
prelude.lib.evalModulenix developxsh
nix run github:darkmatter/prelude#skill -- install # full consumer walkthrough
nix run github:darkmatter/prelude#skill -- options # generated prelude.* reference0. Inspect what already exists
0. 检查现有内容
Before changing anything, look at the repo:
- — flake-parts (
flake.nix) takes the module; anything else (blueprint, a plainflake-parts.lib.mkFlakefunction) usesoutputs, with no restructuring. Note existingprelude.lib.evalModule,inputs, andimportsto preserve them.devShells - /
prelude.nix— inspect any existing sidecar before deciding setup is needed. Edit existing configuration in place; wizard reruns overwrite both files.title.txt - — preserve its existing loader; add
.envrconly when adopting nix-direnv, not alongside another environment-loading strategy.use flake - Existing README and — kept untouched by setup.
docs/
在做任何修改之前,先查看仓库现状:
- — 若使用flake-parts(
flake.nix)则直接引入模块;其他情况(如blueprint、普通flake-parts.lib.mkFlake函数)使用outputs,无需重构现有结构。注意保留已有的prelude.lib.evalModule、inputs和imports配置。devShells - /
prelude.nix— 在确定需要安装前,先检查是否已有sidecar文件。可直接编辑现有配置;重新运行向导会覆盖这两个文件。title.txt - — 保留其现有的加载器;仅在采用nix-direnv时添加
.envrc,不要与其他环境加载策略并用。use flake - 现有README和目录 — 安装过程不会改动这些内容。
docs/
1. Run the wizard (new installs)
1. 运行向导(全新安装)
sh
nix run github:darkmatter/prelude -- wizardSteps: title text + FIGlet font, project name, commands, component toggles
(////), MOTD copy and layout, theme,
confirm. Run from the project root; it needs an interactive terminal. It
writes:
motdmenupromptdocs.envrc- — full options template: your choices active, every other option present as a commented default (the file doubles as inline docs).
prelude.nix - — the rendered wordmark, written beside the config and referenced by bare name, so it resolves from any
title.txtdirectory.-o - (content exactly
.envrc) — only if toggled on and none exists.use flake - With docs enabled: starter +
README.mdat the project root — existing files are kept.docs/getting-started.md
-o pathtitle.txt./README.md./docs/getting-started.md-o-o flake.nixnix flake init -t github:darkmatter/prelude#defaultprelude.*sh
nix run github:darkmatter/prelude -- wizard步骤:标题文本 + FIGlet字体、项目名称、命令、组件开关(////)、MOTD文案与布局、主题、确认。需在项目根目录运行,且需要交互式终端。向导会生成以下文件:
motdmenupromptdocs.envrc- — 完整选项模板:你选择的配置会被启用,其余所有选项以注释形式展示默认值(该文件同时可作为内联文档)。
prelude.nix - — 渲染后的文字标识,与配置文件放在同一目录,通过裸名引用,因此可在任意
title.txt指定的目录中解析。-o - (内容仅为
.envrc) — 仅在开启该开关且不存在该文件时生成。use flake - 若启用文档功能:会在项目根目录生成初始+
README.md— 已有文件会被保留。docs/getting-started.md
-o pathtitle.txt./README.md./docs/getting-started.md-o-o flake.nixnix flake init -t github:darkmatter/prelude#defaultprelude.*2. Wire it into the flake (merge, don't replace)
2. 接入flake(合并而非替换)
The example shows the Prelude-specific lines to merge into the existing
— keep every current input, import, and devshell package:
flake.nixnix
inputs.prelude.url = "github:darkmatter/prelude";示例展示了需要合并到现有中的Prelude相关代码行——请保留所有当前的input、import和devshell包:
flake.nixnix
inputs.prelude.url = "github:darkmatter/prelude";Fresh repo, no pins yet: share one nixpkgs/flake-parts via inputs:
Fresh repo, no pins yet: share one nixpkgs/flake-parts via inputs:
inputs.nixpkgs.follows = "prelude/nixpkgs";
inputs.nixpkgs.follows = "prelude/nixpkgs";
inputs.flake-parts.follows = "prelude/flake-parts";
inputs.flake-parts.follows = "prelude/flake-parts";
flake.lock pins the resolved revision even with the default-branch URL.
flake.lock pins the resolved revision even with the default-branch URL.
Preserve an existing lock; use that revision for wizard/reference commands.
Preserve an existing lock; use that revision for wizard/reference commands.
A URL ending in /<rev> may additionally select an explicit commit or tag.
A URL ending in /<rev> may additionally select an explicit commit or tag.
inside mkFlake's module argument:
inside mkFlake's module argument:
imports = [
inputs.prelude.flakeModules.default
./prelude.nix # generated sidecar; import it, never replace flake.nix
];
imports = [
inputs.prelude.flakeModules.default
./prelude.nix # generated sidecar; import it, never replace flake.nix
];
inside perSystem, alongside existing packages:
inside perSystem, alongside existing packages:
devShells.default = pkgs.mkShell {
packages = [config.packages.prelude-shell];
};
Add only `config.packages.prelude-shell` to the devshell — it bundles every
enabled component and activates via its setup-hook. Do not add
`packages.prelude` (that backs the `prelude` app).
**No flake-parts** (blueprint, a plain `outputs` function): keep the flake as
it is and evaluate the same sidecar where the devshell is defined. It builds
the same packages as the module:
```nixdevShells.default = pkgs.mkShell {
packages = [config.packages.prelude-shell];
};
仅需向devshell中添加`config.packages.prelude-shell`——它打包了所有已启用的组件,并通过其setup-hook激活。不要添加`packages.prelude`(那是`prelude`应用的后端)。
**无flake-parts**的情况(blueprint、普通`outputs`函数):保持现有flake结构不变,在定义devshell的位置评估同一个sidecar文件。它会生成与模块相同的包:
```nixblueprint: devshell.nix (nix/devshells/default.nix with prefix = "nix/")
blueprint: devshell.nix (nix/devshells/default.nix with prefix = "nix/")
{pkgs, inputs, ...}: let
prelude = inputs.prelude.lib.evalModule pkgs ./prelude.nix;
in
pkgs.mkShell {packages = [prelude.packages.prelude-shell];}
Modules receive `pkgs`, so package-backed commands go straight into
`prelude.commands`; there is no `perSystem`. Pass other module arguments
(`self`, `inputs`) through `_module.args` on a wrapper module. Reference:
`examples/without-flake-parts/`.{pkgs, inputs, ...}: let
prelude = inputs.prelude.lib.evalModule pkgs ./prelude.nix;
in
pkgs.mkShell {packages = [prelude.packages.prelude-shell];}
模块会接收`pkgs`参数,因此基于包的命令可直接放入`prelude.commands`;不存在`perSystem`。可通过包装模块的`_module.args`传递其他模块参数(`self`、`inputs`)。参考示例:`examples/without-flake-parts/`。3. Activation paths
3. 激活方式
- — with the prompt component enabled (wizard default) the setup hook sources the generated init: MOTD renders,
nix develop/xland on PATH,docsexports. Nothing extra to configure.STARSHIP_CONFIG - direnv (nix-direnv) — the generated (
.envrc) loads the cached environment and renders the MOTD; new developers need only their existing direnv hook. Preserve an existinguse flakeand its environment loader..envrc - lorri — runs inside the Nix builder, so route it through the same
shellHook: replace.envrcwithuse flake.eval "$(lorri export direnv-adapter)" - Custom —
shellHookis the loader-aware activation line. Nevereval "$(prelude-preflight)"in a shellHook (zsh rejects theexport -fin%names); shell-specific setup belongs inBASH_FUNC_…%%.prelude hook
- — 启用提示符组件(向导默认开启)时,setup hook会加载生成的初始化脚本:渲染MOTD、将
nix develop/x加入PATH、导出docs。无需额外配置。STARSHIP_CONFIG - direnv(nix-direnv) — 生成的(
.envrc)会加载缓存的环境并渲染MOTD;新开发者只需配置好现有的direnv钩子即可。请保留已有的use flake及其环境加载器。.envrc - lorri — 会在Nix构建器中运行,因此需通过同一个
shellHook路由:将.envrc替换为use flake。eval "$(lorri export direnv-adapter)" - 自定义—
shellHook是感知加载器的激活命令。切勿在shellHook中使用eval "$(prelude-preflight)"(zsh会拒绝export -f名称中的BASH_FUNC_…%%);特定于shell的配置应放在%中。prelude hook
4. Customize
4. 自定义配置
Edit the generated (inline config in works too);
every option sits there as a commented default. Highlights:
prelude.nixflake.nix- —
prelude.theme(default),prelude,phosphor,minted,amber,solarized,nord,gruvbox(light),paper,mono; token overrides viaapathy.prelude.palette - — catalogue entries behind
prelude.commands.<key>; the first colon infers the menu group (x→db:migrate). Package-backed commands:db.prelude.lib.fromPkg packages.dev { description = …; motd = 1; } - — one page per file.
prelude.docs.pages = [{text = ./docs/foo.md;}]
编辑生成的(也可在中内联配置);所有选项都以注释默认值的形式列在其中。亮点功能:
prelude.nixflake.nix- — 可选值:
prelude.theme(默认)、prelude、phosphor、minted、amber、solarized、nord、gruvbox(浅色)、paper、mono;可通过apathy覆盖主题令牌。prelude.palette - —
prelude.commands.<key>命令背后的目录条目;第一个冒号用于推断菜单分组(x→db:migrate)。基于包的命令:db。prelude.lib.fromPkg packages.dev { description = …; motd = 1; } - — 每个文件对应一个页面。
prelude.docs.pages = [{text = ./docs/foo.md;}]
5. Git-track new files, then verify
5. 跟踪新文件到Git,然后验证
Git-backed flakes exclude untracked files. Inspect and
stage only the intended files created or edited for this setup; do not stage
unrelated changes or suppress errors. Include a newly created
when referenced, the actual sidecar and sibling
locations (including custom paths), and any newly referenced docs.
Do not stage a pre-existing merely because the wizard uses it.
No commit is required for local evaluation.
git status --shortgit addREADME.mdtitle.txt-o.envrcAlternatively, verify with and
to include the working directory without changing the index. This can include
normally Git-excluded files, so use it only on a trusted local working tree.
nix develop path:.nix flake check path:.Then real smoke checks:
sh
nix develop # MOTD renders, themed prompt appears
x --list # catalogue table prints non-interactively
x # picker opens (q quits)
docs # viewer opens when docs pages exist (q quits)
motd # banner reprints on demand
nix flake check # full build gate (heavier)Non-interactive stays silent by design (no banner in build
logs) — use the interactive shell to see the MOTD.
nix develop -c …基于Git的flake会排除未跟踪的文件。检查的输出,仅暂存本次安装创建或修改的目标文件;不要暂存无关更改,也不要忽略的错误。若有新生成的被引用,请将其纳入,同时包括实际的sidecar文件和同级的(包括自定义路径),以及所有新引用的文档。不要仅仅因为向导使用了就暂存已存在的文件。本地评估不需要提交。
git status --shortgit addREADME.mdtitle.txt-o.envrc.envrc或者,可使用和来验证,这样会包含工作目录的内容而无需修改暂存区。这可能会包含通常被Git忽略的文件,因此仅在可信的本地工作树上使用。
nix develop path:.nix flake check path:.然后进行实际冒烟测试:
sh
nix develop # MOTD renders, themed prompt appears
x --list # catalogue table prints non-interactively
x # picker opens (q quits)
docs # viewer opens when docs pages exist (q quits)
motd # banner reprints on demand
nix flake check # full build gate (heavier)非交互式的默认保持静默(构建日志中不会出现横幅)——请使用交互式shell查看MOTD。
nix develop -c …Handoff
交接
- — adapt an existing justfile.
/prelude-just <arg> - — author docs-viewer pages.
/prelude-docs - — other Prelude work.
/prelude <anything>
- — 适配现有的justfile。
/prelude-just <arg> - — 编写文档查看器页面。
/prelude-docs - — 其他Prelude相关工作。
/prelude <anything>