nix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nix Skill

Nix 技能指南

1. nix build

1. nix build

  • YOU MUST: Always use
    --no-link
    option with
    nix build
    sh
    nix build .#rumdl --no-link
  • IMPORTANT: Without
    --no-link
    , a
    ./result
    symlink is created
  • 必须:使用
    nix build
    时务必添加
    --no-link
    选项
    sh
    nix build .#rumdl --no-link
  • 重要说明:如果不添加
    --no-link
    ,会创建一个
    ./result
    符号链接

2. nix run

2. nix run

  • IMPORTANT: Packages registered in packages can be run with
    nix run
    sh
    nix run .#pike -- scan -d ./terraform
  • 重要说明:已在包列表中注册的包可通过
    nix run
    运行
    sh
    nix run .#pike -- scan -d ./terraform

3. Adding Custom Packages

3. 添加自定义包

  • YOU MUST: See CONTRIBUTING.md section 1.4.2 for adding new custom packages
  • IMPORTANT: Hash acquisition flow
    1. Get
      hash
      using nurl:
      nurl https://github.com/<owner>/<repo> <tag>
    2. Get
      vendorHash
      /
      cargoHash
      via build error (
      got:
      line)
  • IMPORTANT: Add
    doCheck = false;
    if tests fail
  • 必须:添加新自定义包请查看CONTRIBUTING.md的1.4.2章节
  • 重要说明:哈希值获取流程
    1. 使用nurl获取
      hash
      nurl https://github.com/<owner>/<repo> <tag>
    2. 通过构建错误信息(
      got:
      行)获取
      vendorHash
      /
      cargoHash
  • 重要说明:如果测试失败,添加
    doCheck = false;

4. nurl

4. nurl

  • IMPORTANT: nurl generates Nix fetcher calls from repository URLs
    sh
    nurl https://github.com/rvben/rumdl v0.0.206
  • IMPORTANT: Output can be used directly in fetchFromGitHub
    nix
    fetchFromGitHub {
      owner = "rvben";
      repo = "rumdl";
      rev = "v0.0.206";
      hash = "sha256-XXX...";
    }
  • IMPORTANT: For cargoHash/vendorHash, use build error method (nurl does not support these)
  • 重要说明:nurl可根据仓库URL生成Nix获取器调用代码
    sh
    nurl https://github.com/rvben/rumdl v0.0.206
  • 重要说明:输出结果可直接用于fetchFromGitHub
    nix
    fetchFromGitHub {
      owner = "rvben";
      repo = "rumdl";
      rev = "v0.0.206";
      hash = "sha256-XXX...";
    }
  • 重要说明:对于cargoHash/vendorHash,请使用构建错误信息的方法获取(nurl不支持这些)