nixomatic

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nixomatic 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
flake.nix
files, you construct a URL like
https://nixomatic.com/?p=nodejs,python3
and pass it directly to
nix develop
. The service generates and serves a Nix flake with the requested packages -- no local Nix configuration or flake authoring required.
Use 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参数即时创建可复现的开发环境。无需编写和维护
flake.nix
文件,你只需构造一个类似
https://nixomatic.com/?p=nodejs,python3
的URL,并直接将其传入
nix develop
命令即可。该服务会生成并提供包含所需包的Nix flake——无需本地Nix配置或编写flake。
当用户要求构建、编译、测试、代码检查、格式化、类型检查、运行或搭建项目时,或者当命令因缺少工具或运行时而失败时,即可使用此Skill。

Detecting Nix vs Docker

检测Nix与Docker环境

Before running any environment command, determine which runtime is available:
  1. Check if
    nix
    is on PATH (
    which nix
    ). If found, use Nix directly.
  2. If
    nix
    is not found, check if
    docker
    is on PATH (
    which docker
    ). If found, use the Docker wrapper.
  3. If neither is available, inform the user that one of Nix or Docker must be installed and provide links:
在运行任何环境命令之前,需确定可用的运行时环境:
  1. 检查
    nix
    是否在PATH中(执行
    which nix
    )。若存在,则直接使用Nix。
  2. 若未找到
    nix
    ,检查
    docker
    是否在PATH中(执行
    which docker
    )。若存在,则使用Docker包装器。
  3. 若两者均不可用,告知用户必须安装Nix或Docker之一,并提供链接:

Analyzing the Project

分析项目

Determine what packages the project needs by scanning files in this order:
  1. Check for existing nixomatic URL in README.md: Look for a
    ## Development Environment
    section containing a
    nixomatic.com
    URL. If found, reuse that URL as the baseline (it represents the last known-good package set). Add packages only if something is missing.
  2. Check for
    flake.nix
    : If the project root contains a
    flake.nix
    , prefer the project's own flake over nixomatic. Run commands with
    nix develop --command -- <cmd>
    using the local flake. Do not generate a nixomatic URL in this case.
  3. Detect languages and runtimes from project files:
    • package.json
      ->
      nodejs
    • Cargo.toml
      ->
      rustc,cargo
    • go.mod
      ->
      go
    • requirements.txt
      ,
      setup.py
      ,
      pyproject.toml
      ->
      python3
    • Gemfile
      ->
      ruby
    • build.gradle
      ,
      build.gradle.kts
      ,
      pom.xml
      ->
      jdk
    • mix.exs
      ->
      elixir
    • *.sln
      ,
      *.csproj
      ,
      *.fsproj
      ->
      dotnet-sdk
    • composer.json
      ->
      php
    • Package.swift
      ->
      swift
    • dune-project
      ,
      *.opam
      ->
      ocaml
    • stack.yaml
      ,
      *.cabal
      ->
      ghc,cabal-install
    • pubspec.yaml
      ->
      dart
    • zig.zon
      ,
      build.zig
      ->
      zig
  4. Detect build tools:
    • Makefile
      ->
      gnumake
    • CMakeLists.txt
      ->
      cmake
    • meson.build
      ->
      meson
    • Justfile
      ->
      just
    • Taskfile.yml
      ->
      go-task
    • Rakefile
      (without Gemfile) ->
      ruby
  5. Detect additional tools from config files:
    • .eslintrc*
      ,
      eslint.config.*
      -> (already covered by nodejs)
    • Dockerfile
      ->
      docker
    • .terraform*
      ->
      terraform
    • serverless.yml
      ->
      nodejs
    • Makefile
      containing
      protoc
      ->
      protobuf
按以下顺序扫描文件,确定项目所需的包:
  1. 检查README.md中已有的nixomatic URL:查找包含
    nixomatic.com
    URL的
    ## Development Environment
    章节。若找到,复用该URL作为基础(它代表已知可用的包集合)。仅当缺少某些包时再添加新包。
  2. 检查
    flake.nix
    文件
    :若项目根目录包含
    flake.nix
    ,优先使用项目自身的flake而非nixomatic。使用本地flake通过
    nix develop --command -- <cmd>
    运行命令。此情况下无需生成nixomatic URL。
  3. 从项目文件检测语言与运行时
    • package.json
      ->
      nodejs
    • Cargo.toml
      ->
      rustc,cargo
    • go.mod
      ->
      go
    • requirements.txt
      ,
      setup.py
      ,
      pyproject.toml
      ->
      python3
    • Gemfile
      ->
      ruby
    • build.gradle
      ,
      build.gradle.kts
      ,
      pom.xml
      ->
      jdk
    • mix.exs
      ->
      elixir
    • *.sln
      ,
      *.csproj
      ,
      *.fsproj
      ->
      dotnet-sdk
    • composer.json
      ->
      php
    • Package.swift
      ->
      swift
    • dune-project
      ,
      *.opam
      ->
      ocaml
    • stack.yaml
      ,
      *.cabal
      ->
      ghc,cabal-install
    • pubspec.yaml
      ->
      dart
    • zig.zon
      ,
      build.zig
      ->
      zig
  4. 检测构建工具
    • Makefile
      ->
      gnumake
    • CMakeLists.txt
      ->
      cmake
    • meson.build
      ->
      meson
    • Justfile
      ->
      just
    • Taskfile.yml
      ->
      go-task
    • Rakefile
      (无Gemfile时)->
      ruby
  5. 从配置文件检测额外工具
    • .eslintrc*
      ,
      eslint.config.*
      -> (已包含在nodejs中)
    • Dockerfile
      ->
      docker
    • .terraform*
      ->
      terraform
    • serverless.yml
      ->
      nodejs
    • 包含
      protoc
      Makefile
      ->
      protobuf

Common Package Mappings

常见包映射关系

Project file / indicatorNix packages
package.json
nodejs
Cargo.toml
rustc
,
cargo
go.mod
go
requirements.txt
python3
pyproject.toml
python3
Gemfile
ruby
pom.xml
/
build.gradle
jdk
mix.exs
elixir
composer.json
php
*.csproj
/
*.fsproj
dotnet-sdk
Package.swift
swift
stack.yaml
/
*.cabal
ghc
,
cabal-install
pubspec.yaml
dart
build.zig
/
zig.zon
zig
Makefile
gnumake
CMakeLists.txt
cmake
meson.build
meson
Justfile
just
Taskfile.yml
go-task
curl
needed
curl
git
needed
git
jq
needed
jq
openssl
needed
openssl
pkg-config
needed
pkg-config
protobuf
needed
protobuf
项目文件 / 标识Nix 包
package.json
nodejs
Cargo.toml
rustc
,
cargo
go.mod
go
requirements.txt
python3
pyproject.toml
python3
Gemfile
ruby
pom.xml
/
build.gradle
jdk
mix.exs
elixir
composer.json
php
*.csproj
/
*.fsproj
dotnet-sdk
Package.swift
swift
stack.yaml
/
*.cabal
ghc
,
cabal-install
pubspec.yaml
dart
build.zig
/
zig.zon
zig
Makefile
gnumake
CMakeLists.txt
cmake
meson.build
meson
Justfile
just
Taskfile.yml
go-task
需要
curl
curl
需要
git
git
需要
jq
jq
需要
openssl
openssl
需要
pkg-config
pkg-config
需要
protobuf
protobuf

Constructing the URL

构造URL

Build the nixomatic URL from the detected packages:
https://nixomatic.com/?p=pkg1,pkg2,pkg3
Use the short
p
query parameter with comma-separated package names. For example, a Node.js project with a Makefile becomes:
https://nixomatic.com/?p=nodejs,gnumake
To pin a specific package version, use
@version
syntax:
https://nixomatic.com/?p=nodejs@20.11.1,python3
To pin to a specific nixpkgs revision, use
:revision
syntax:
https://nixomatic.com/?p=python3:3b93cf5
根据检测到的包构建nixomatic URL:
https://nixomatic.com/?p=pkg1,pkg2,pkg3
使用短参数
p
,包名用逗号分隔。例如,包含Makefile的Node.js项目对应的URL为:
https://nixomatic.com/?p=nodejs,gnumake
要固定特定包版本,使用
@version
语法:
https://nixomatic.com/?p=nodejs@20.11.1,python3
要固定到特定nixpkgs修订版本,使用
:revision
语法:
https://nixomatic.com/?p=python3:3b93cf5

Command 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-config

Docker

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-config
Note: The Docker commands include
-v "$(pwd):/workspace" -w /workspace
to mount the current project directory into the container. This is essential for real project work so that build tools can access project files.
在环境中运行命令:
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 /workspace
,用于将当前项目目录挂载到容器中。这对于实际项目工作至关重要,这样构建工具才能访问项目文件。

Agent Workflow

Agent工作流

Follow these steps when the user asks to build, test, lint, format, or set up a project:
  1. Check for
    flake.nix
    : If the project has its own
    flake.nix
    , use it directly with
    nix develop --command -- <cmd>
    . Skip the remaining steps.
  2. Check README.md for existing URL: Look for a
    ## Development Environment
    section containing a
    nixomatic.com/?p=
    URL. If found, use that URL as the starting point.
  3. 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.
  4. Construct the URL: Build
    https://nixomatic.com/?p=pkg1,pkg2,...
    from the detected packages. If reusing a README URL, merge any new packages into it.
  5. Detect runtime: Check for
    nix
    on PATH, then
    docker
    . Select the appropriate command template.
  6. Execute the command: Run the user's requested operation (build, test, lint, etc.) inside the nixomatic environment using the appropriate command template.
  7. Handle missing packages: If a command fails because a tool is not found (e.g.,
    command not found: cmake
    ), add the missing package to the URL and retry the command.
  8. Update README.md: After a successful command execution, ensure the project's README.md contains an up-to-date
    ## Development Environment
    section with the working nixomatic URL. See the README.md Maintenance section below.
当用户要求构建、测试、代码检查、格式化或搭建项目时,遵循以下步骤:
  1. 检查
    flake.nix
    :若项目有自己的
    flake.nix
    ,直接通过
    nix develop --command -- <cmd>
    使用它。跳过剩余步骤。
  2. 检查README.md中的已有URL:查找包含
    nixomatic.com/?p=
    URL的
    ## Development Environment
    章节。若找到,以此URL为起点。
  3. 分析项目文件:扫描项目根目录的语言文件、构建工具配置和其他标识。根据上述映射关系确定所需的包集合。
  4. 构造URL:根据检测到的包构建
    https://nixomatic.com/?p=pkg1,pkg2,...
    。若复用README中的URL,将新包合并到其中。
  5. 检测运行时:检查PATH中是否有
    nix
    ,再检查
    docker
    。选择对应的命令模板。
  6. 执行命令:使用合适的命令模板,在nixomatic环境中运行用户请求的操作(构建、测试、代码检查等)。
  7. 处理缺失的包:若命令因工具未找到而失败(例如
    command not found: cmake
    ),将缺失的包添加到URL中并重试命令。
  8. 更新README.md:命令成功执行后,确保项目的README.md包含最新的
    ## Development Environment
    章节,其中包含可用的nixomatic URL。请参阅下方的README.md维护部分。

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
    ## Development Environment
    heading that contains a
    nixomatic.com
    URL.
  • 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中搜索包含
    nixomatic.com
    URL的
    ## Development Environment
    标题。
  • 若找到,当包集合变化时更新URL。
  • 若未找到,将该章节追加到README.md末尾(若存在"License"或"Contributing"等最终章节,则添加到这些章节之前)。

Section template

章节模板

Use this template for the Development Environment section. Replace
<packages>
with the actual comma-separated package list:
markdown
undefined
使用以下模板作为开发环境章节。将
<packages>
替换为实际的逗号分隔包列表:
markdown
undefined

Development 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-config
bash
nix \
    --extra-experimental-features 'nix-command flakes' \
    develop 'https://nixomatic.com/?p=<packages>' \
      --accept-flake-config

Using 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-config
undefined
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
undefined

Keeping 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

错误处理

ErrorCauseFix
command not found: <tool>
Package missing from URLAdd the package to the
p=
parameter and retry
error: unable to download
Network issue or invalid URLCheck internet connectivity and verify the URL is well-formed
error: flake has no attribute
Unknown package nameVerify the package name exists in nixpkgs (search at https://search.nixos.org/packages)
docker: command not found
Docker not installedFall back to Nix, or ask user to install Docker
nix: command not found
Nix not installedFall back to Docker, or ask user to install Nix
error: experimental Nix feature 'flakes' is disabled
Old Nix without flakes flagThe
--extra-experimental-features 'nix-command flakes'
flag should handle this; if not, the user needs to update Nix
Permission denied on Docker socketUser not in docker groupSuggest
sudo usermod -aG docker $USER
or running with
sudo
错误信息原因解决方法
command not found: <tool>
URL中缺失对应包将该包添加到
p=
参数中并重试
error: unable to download
网络问题或URL无效检查网络连接并验证URL格式是否正确
error: flake has no attribute
包名不存在验证包名是否在nixpkgs中存在(可在https://search.nixos.org/packages搜索)
docker: command not found
Docker未安装切换到Nix,或要求用户安装Docker
nix: command not found
Nix未安装切换到Docker,或要求用户安装Nix
error: experimental Nix feature 'flakes' is disabled
Nix版本过旧,未启用flakes
--extra-experimental-features 'nix-command flakes'
参数应可解决此问题;若无效,用户需更新Nix
Docker套接字权限被拒绝用户不在docker用户组中建议执行
sudo usermod -aG docker $USER
或使用
sudo
运行命令