nixomatic
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNixomatic Skill
Nixomatic Skill
Overview
概述
Nixomatic is a Nix flake generator service that creates reproducible development environments on-the-fly from URL parameters. Instead of writing and maintaining files, you construct a URL like and pass it directly to . The service generates and serves a Nix flake with the requested packages -- no local Nix configuration or flake authoring required.
flake.nixhttps://nixomatic.com/?p=nodejs,python3nix developUse this skill whenever the user asks to build, compile, test, lint, format, type-check, run, or set up a project, or when a command fails because a tool or runtime is missing.
Nixomatic 是一个Nix flake生成服务,可通过URL参数即时创建可复现的开发环境。无需编写和维护文件,你只需构造一个类似的URL,并直接将其传入命令即可。该服务会生成并提供包含所需包的Nix flake——无需本地Nix配置或编写flake。
flake.nixhttps://nixomatic.com/?p=nodejs,python3nix develop当用户要求构建、编译、测试、代码检查、格式化、类型检查、运行或搭建项目时,或者当命令因缺少工具或运行时而失败时,即可使用此Skill。
Detecting Nix vs Docker
检测Nix与Docker环境
Before running any environment command, determine which runtime is available:
- Check if is on PATH (
nix). If found, use Nix directly.which nix - If is not found, check if
nixis on PATH (docker). If found, use the Docker wrapper.which docker - If neither is available, inform the user that one of Nix or Docker must be installed and provide links:
在运行任何环境命令之前,需确定可用的运行时环境:
- 检查是否在PATH中(执行
nix)。若存在,则直接使用Nix。which nix - 若未找到,检查
nix是否在PATH中(执行docker)。若存在,则使用Docker包装器。which docker - 若两者均不可用,告知用户必须安装Nix或Docker之一,并提供链接:
Analyzing the Project
分析项目
Determine what packages the project needs by scanning files in this order:
-
Check for existing nixomatic URL in README.md: Look for asection containing a
## Development EnvironmentURL. If found, reuse that URL as the baseline (it represents the last known-good package set). Add packages only if something is missing.nixomatic.com -
Check for: If the project root contains a
flake.nix, prefer the project's own flake over nixomatic. Run commands withflake.nixusing the local flake. Do not generate a nixomatic URL in this case.nix develop --command -- <cmd> -
Detect languages and runtimes from project files:
- ->
package.jsonnodejs - ->
Cargo.tomlrustc,cargo - ->
go.modgo - ,
requirements.txt,setup.py->pyproject.tomlpython3 - ->
Gemfileruby - ,
build.gradle,build.gradle.kts->pom.xmljdk - ->
mix.exselixir - ,
*.sln,*.csproj->*.fsprojdotnet-sdk - ->
composer.jsonphp - ->
Package.swiftswift - ,
dune-project->*.opamocaml - ,
stack.yaml->*.cabalghc,cabal-install - ->
pubspec.yamldart - ,
zig.zon->build.zigzig
-
Detect build tools:
- ->
Makefilegnumake - ->
CMakeLists.txtcmake - ->
meson.buildmeson - ->
Justfilejust - ->
Taskfile.ymlgo-task - (without Gemfile) ->
Rakefileruby
-
Detect additional tools from config files:
- ,
.eslintrc*-> (already covered by nodejs)eslint.config.* - ->
Dockerfiledocker - ->
.terraform*terraform - ->
serverless.ymlnodejs - containing
Makefile->protocprotobuf
按以下顺序扫描文件,确定项目所需的包:
-
检查README.md中已有的nixomatic URL:查找包含URL的
nixomatic.com章节。若找到,复用该URL作为基础(它代表已知可用的包集合)。仅当缺少某些包时再添加新包。## Development Environment -
检查文件:若项目根目录包含
flake.nix,优先使用项目自身的flake而非nixomatic。使用本地flake通过flake.nix运行命令。此情况下无需生成nixomatic URL。nix develop --command -- <cmd> -
从项目文件检测语言与运行时:
- ->
package.jsonnodejs - ->
Cargo.tomlrustc,cargo - ->
go.modgo - ,
requirements.txt,setup.py->pyproject.tomlpython3 - ->
Gemfileruby - ,
build.gradle,build.gradle.kts->pom.xmljdk - ->
mix.exselixir - ,
*.sln,*.csproj->*.fsprojdotnet-sdk - ->
composer.jsonphp - ->
Package.swiftswift - ,
dune-project->*.opamocaml - ,
stack.yaml->*.cabalghc,cabal-install - ->
pubspec.yamldart - ,
zig.zon->build.zigzig
-
检测构建工具:
- ->
Makefilegnumake - ->
CMakeLists.txtcmake - ->
meson.buildmeson - ->
Justfilejust - ->
Taskfile.ymlgo-task - (无Gemfile时)->
Rakefileruby
-
从配置文件检测额外工具:
- ,
.eslintrc*-> (已包含在nodejs中)eslint.config.* - ->
Dockerfiledocker - ->
.terraform*terraform - ->
serverless.ymlnodejs - 包含的
protoc->Makefileprotobuf
Common Package Mappings
常见包映射关系
| Project file / indicator | Nix packages |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| 项目文件 / 标识 | Nix 包 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
需要 | |
需要 | |
需要 | |
需要 | |
需要 | |
需要 | |
Constructing the URL
构造URL
Build the nixomatic URL from the detected packages:
https://nixomatic.com/?p=pkg1,pkg2,pkg3Use the short query parameter with comma-separated package names. For example, a Node.js project with a Makefile becomes:
phttps://nixomatic.com/?p=nodejs,gnumakeTo pin a specific package version, use syntax:
@versionhttps://nixomatic.com/?p=nodejs@20.11.1,python3To pin to a specific nixpkgs revision, use syntax:
:revisionhttps://nixomatic.com/?p=python3:3b93cf5根据检测到的包构建nixomatic URL:
https://nixomatic.com/?p=pkg1,pkg2,pkg3使用短参数,包名用逗号分隔。例如,包含Makefile的Node.js项目对应的URL为:
phttps://nixomatic.com/?p=nodejs,gnumake要固定特定包版本,使用语法:
@versionhttps://nixomatic.com/?p=nodejs@20.11.1,python3要固定到特定nixpkgs修订版本,使用语法:
:revisionhttps://nixomatic.com/?p=python3:3b93cf5Command Templates
命令模板
Nix (direct)
Nix(直接使用)
Run a command inside the environment:
bash
nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-config \
--command -- <cmd>Enter an interactive shell:
bash
nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-config在环境中运行命令:
bash
nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-config \
--command -- <cmd>进入交互式shell:
bash
nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-configDocker
Docker
Run a command inside the environment:
bash
docker run -v nix-store:/nix -v "$(pwd):/workspace" -w /workspace --rm nixos/nix nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-config \
--command -- <cmd>Enter an interactive shell:
bash
docker run -v nix-store:/nix -v "$(pwd):/workspace" -w /workspace --rm -it nixos/nix nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-configNote: The Docker commands include to mount the current project directory into the container. This is essential for real project work so that build tools can access project files.
-v "$(pwd):/workspace" -w /workspace在环境中运行命令:
bash
docker run -v nix-store:/nix -v "$(pwd):/workspace" -w /workspace --rm nixos/nix nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-config \
--command -- <cmd>进入交互式shell:
bash
docker run -v nix-store:/nix -v "$(pwd):/workspace" -w /workspace --rm -it nixos/nix nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-config注意: Docker命令包含,用于将当前项目目录挂载到容器中。这对于实际项目工作至关重要,这样构建工具才能访问项目文件。
-v "$(pwd):/workspace" -w /workspaceAgent Workflow
Agent工作流
Follow these steps when the user asks to build, test, lint, format, or set up a project:
-
Check for: If the project has its own
flake.nix, use it directly withflake.nix. Skip the remaining steps.nix develop --command -- <cmd> -
Check README.md for existing URL: Look for asection containing a
## Development EnvironmentURL. If found, use that URL as the starting point.nixomatic.com/?p= -
Analyze project files: Scan the project root for language files, build tool configs, and other indicators. Determine the required package set using the mappings above.
-
Construct the URL: Buildfrom the detected packages. If reusing a README URL, merge any new packages into it.
https://nixomatic.com/?p=pkg1,pkg2,... -
Detect runtime: Check foron PATH, then
nix. Select the appropriate command template.docker -
Execute the command: Run the user's requested operation (build, test, lint, etc.) inside the nixomatic environment using the appropriate command template.
-
Handle missing packages: If a command fails because a tool is not found (e.g.,), add the missing package to the URL and retry the command.
command not found: cmake -
Update README.md: After a successful command execution, ensure the project's README.md contains an up-to-datesection with the working nixomatic URL. See the README.md Maintenance section below.
## Development Environment
当用户要求构建、测试、代码检查、格式化或搭建项目时,遵循以下步骤:
-
检查:若项目有自己的
flake.nix,直接通过flake.nix使用它。跳过剩余步骤。nix develop --command -- <cmd> -
检查README.md中的已有URL:查找包含URL的
nixomatic.com/?p=章节。若找到,以此URL为起点。## Development Environment -
分析项目文件:扫描项目根目录的语言文件、构建工具配置和其他标识。根据上述映射关系确定所需的包集合。
-
构造URL:根据检测到的包构建。若复用README中的URL,将新包合并到其中。
https://nixomatic.com/?p=pkg1,pkg2,... -
检测运行时:检查PATH中是否有,再检查
nix。选择对应的命令模板。docker -
执行命令:使用合适的命令模板,在nixomatic环境中运行用户请求的操作(构建、测试、代码检查等)。
-
处理缺失的包:若命令因工具未找到而失败(例如),将缺失的包添加到URL中并重试命令。
command not found: cmake -
更新README.md:命令成功执行后,确保项目的README.md包含最新的章节,其中包含可用的nixomatic URL。请参阅下方的README.md维护部分。
## Development Environment
README.md Maintenance
README.md维护
After successfully running commands in a nixomatic environment, ensure the project's README.md documents how to reproduce it. This is the primary artifact of this skill.
在nixomatic环境中成功运行命令后,确保项目的README.md记录了如何复现该环境。这是此Skill的核心产出物。
Finding or creating the section
查找或创建章节
- Search README.md for a heading that contains a
## Development EnvironmentURL.nixomatic.com - If found, update the URL if the package set has changed.
- If not found, append the section to the end of README.md (before any final sections like "License" or "Contributing" if they exist).
- 在README.md中搜索包含URL的
nixomatic.com标题。## Development Environment - 若找到,当包集合变化时更新URL。
- 若未找到,将该章节追加到README.md末尾(若存在"License"或"Contributing"等最终章节,则添加到这些章节之前)。
Section template
章节模板
Use this template for the Development Environment section. Replace with the actual comma-separated package list:
<packages>markdown
undefined使用以下模板作为开发环境章节。将替换为实际的逗号分隔包列表:
<packages>markdown
undefinedDevelopment Environment
Development Environment
This project uses nixomatic for reproducible development environments.
This project uses nixomatic for reproducible development environments.
Using Nix
Using Nix
bash
nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-configbash
nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-configUsing Docker
Using Docker
bash
docker run -v nix-store:/nix -v "$(pwd):/workspace" -w /workspace --rm -it nixos/nix nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-configundefinedbash
docker run -v nix-store:/nix -v "$(pwd):/workspace" -w /workspace --rm -it nixos/nix nix \
--extra-experimental-features 'nix-command flakes' \
develop 'https://nixomatic.com/?p=<packages>' \
--accept-flake-configundefinedKeeping the URL in sync
保持URL同步
- When packages are added (e.g., a missing tool was discovered), update the URL in the README.md section.
- When packages are removed (e.g., a dependency was dropped), update the URL accordingly.
- Always use the same URL in both the Nix and Docker command blocks.
- 当添加包时(例如发现缺失的工具),更新README.md章节中的URL。
- 当移除包时(例如依赖被删除),相应更新URL。
- Nix和Docker命令块中始终使用相同的URL。
Error Handling
错误处理
| Error | Cause | Fix |
|---|---|---|
| Package missing from URL | Add the package to the |
| Network issue or invalid URL | Check internet connectivity and verify the URL is well-formed |
| Unknown package name | Verify the package name exists in nixpkgs (search at https://search.nixos.org/packages) |
| Docker not installed | Fall back to Nix, or ask user to install Docker |
| Nix not installed | Fall back to Docker, or ask user to install Nix |
| Old Nix without flakes flag | The |
| Permission denied on Docker socket | User not in docker group | Suggest |
| 错误信息 | 原因 | 解决方法 |
|---|---|---|
| URL中缺失对应包 | 将该包添加到 |
| 网络问题或URL无效 | 检查网络连接并验证URL格式是否正确 |
| 包名不存在 | 验证包名是否在nixpkgs中存在(可在https://search.nixos.org/packages搜索) |
| Docker未安装 | 切换到Nix,或要求用户安装Docker |
| Nix未安装 | 切换到Docker,或要求用户安装Nix |
| Nix版本过旧,未启用flakes | |
| Docker套接字权限被拒绝 | 用户不在docker用户组中 | 建议执行 |