|
Tags: Mobile edit Mobile web edit |
| (35 intermediate revisions by the same user not shown) |
| Line 25: |
Line 25: |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 如果你没有修改 <code>services.hydra.dbi</code> 选项,该模块会自动启用 [[PostgreSQL|postgresql]]。数据库结构会由 Hydra 服务自动创建;但请注意,部分状态数据会存储在数据库中,因此目前尚无法实现完全无状态的配置——请务必做好备份。 |
| The module will automatically enable [[PostgreSQL|postgresql]] if you do not change the <code>services.hydra.dbi</code> option. Database layout will be created automatically by the Hydra service, however keep in mind that some state will be stored in the database and a complete stateless configuration is currently not possible - do your backups.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | * 请参阅 nixos-option,或访问 [https://search.nixos.org/options?query=services.hydra NixOS 选项页面] 以查看所有可用选项 |
| * See nixos-option or the [https://search.nixos.org/options?query=services.hydra Nixos Options page] for all options | |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Web_Configuration"></span> |
| === Web Configuration === | | === 网站配置 === |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |
| Line 47: |
Line 42: |
| </syntaxHighlight> | | </syntaxHighlight> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Virtual_machine"></span> |
| === Virtual machine === | | === 虚拟机 === |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 如果未显式进行其他配置,Hydra 将默认使用 localhost 作为构建机。默认情况下,用于在虚拟机中执行构建的系统特性(如 “kvm” 或 “nixos-test”)不会被启用。此类作业将会无限期地处于排队状态。可以通过如下方式启用这些选项: |
| If not configured explicitly to do otherwise, Hydra will specify localhost as the default build machine. By default, system features enabling builds to be performed in virtual machines like "kvm" or "nixos-test" are not enabled. Such jobs will be queued indefinitely. Those options can be activated as follows:
| |
| </div>
| |
|
| |
|
| <syntaxHighlight lang=nix> | | <syntaxHighlight lang=nix> |
| Line 68: |
Line 60: |
| </syntaxHighlight> | | </syntaxHighlight> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 此选项会导致创建文件 /etc/nix/machines。若 Hydra 服务配置仍设置为 buildMachinesFiles = [],则该文件将被忽略,因此请移除此选项,或将 <code>/etc/nix/machines</code> 添加到该配置中。 |
| This option leads to the file /etc/nix/machines being created. If the hydra service config is still set to buildMachinesFiles = [], then it will be ignored, so remove this option again or add <code>/etc/nix/machines</code> to it.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Flake_jobset"></span> |
| == Flake jobset == | | == Flake 作业集 == |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 按照如下方式配置作业集: |
| Configure jobset to the following:
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * Type: [[Flakes|Flake]] | | * Type: [[Flakes|Flake]] |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |
| Line 88: |
Line 73: |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | Flake 输出应包含属性 <code>hydraJobs</code>,其值为一个属性集;该属性集可包含嵌套结构,并可引用 derivation。 |
| The Flake output should have the attribute <code>hydraJobs</code> containing an attribute set that may be nested and reference derivations.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 一个使 Hydra 构建所有软件包的示例 Flake 输出可能如下所示: |
| A sample Flake output that makes Hydra build all packages could look like this:
| |
| </div>
| |
|
| |
|
| <syntaxHighlight lang=nix> | | <syntaxHighlight lang=nix> |
| Line 114: |
Line 95: |
| </syntaxHighlight> | | </syntaxHighlight> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Restricted_Mode"></span> |
| === Restricted Mode === | | === 受限模式 === |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | Hydra 会在 [https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-restrict-eval 受限模式] 下对 flakes 进行求值。此模式会阻止访问 nix store 之外的文件,包括作为 flake 输入获取的文件。请更新你的 <code>nix.settings.allowed-uris</code>,加入你预期用于获取 flake 输入的 URI 前缀: |
| Hydra evaluates flakes in [https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-restrict-eval restricted mode]. This prevents access to files outside of the nix store, including those fetched as flake inputs. Update your <code>nix.settings.allowed-uris</code> to include URI prefixes from which you expect flake inputs to be fetched: | |
| </div>
| |
|
| |
|
| <syntaxHighlight lang=nix> | | <syntaxHighlight lang=nix> |
| Line 130: |
Line 108: |
| </syntaxHighlight> | | </syntaxHighlight> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Build_a_single_Package_from_nixpkgs"></span> |
| == Build a single Package from nixpkgs == | | == 从 nixpkgs 构建单个软件包 == |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |
| Line 138: |
Line 115: |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Imperative_Building"></span> |
| === Imperative Building === | | === 命令式构建 === |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 这些步骤是构建 <code>hello</code> 软件包所必需的。 |
| These steps are required to build the <code>hello</code> package.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | # 使用 <code>hydra-create-user</code> 创建用户后,登录 Hydra |
| # log into Hydra after creating a user with <code>hydra-create-user</code> | |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | # 创建新项目 |
| # create new project | |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * identifier: example-hello | | * identifier: example-hello |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * display name: example-hello | | * display name: example-hello |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| # Actions -> Create jobset | | # Actions -> Create jobset |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * identifier: hello | | * identifier: hello |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | * Nix expression: <code>release.nix</code> in <code>hydra-example</code> -> 将对给定输入中的文件 release.nix 进行求值 |
| * Nix expression: <code>release.nix</code> in <code>hydra-example</code> -> will evaluate the file release.nix in the given input | |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * check interval: 60 | | * check interval: 60 |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * scheduling shares: 1 | | * scheduling shares: 1 |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * Inputs: | | * Inputs: |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |
| Line 197: |
Line 151: |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 创建后,该 jobset 应会进入'''求值阶段'''(evaluation phase),此阶段将会获取各项输入。由于在继续之前需要先下载完整的 <code>nixpkgs</code> 仓库,因此这一阶段可能需要一些时间。求值完成后,结果应为一个将被构建的单一作业。 |
| After creation, the jobset should be in the '''evaluation phase''' where inputs will be fetched. This phase may take some time as the complete <code>nixpkgs</code> repository needs to be downloaded before continuing. The result of the evaluation should be a single job which will get built.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Declarative_Building"></span> |
| === Declarative Building === | | === 声明式构建 === |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |
| Line 209: |
Line 160: |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Hydra_Internals"></span> |
| == Hydra Internals == | | == Hydra 内部机制 == |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Definitions"></span> |
| === Definitions === | | === 定义 === |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 本小节概述了 Hydra 专用定义及其配置方法。 |
| This subsection provides an overview of the Hydra-specific definitions and how to configure them.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Project"></span> |
| ==== Project ==== | | ==== 项目 ==== |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 一组来自单一输入(例如一次 git 检出)的 Job 集群,是你首先需要创建的内容。每个 Job 都应能够独立于其他 Job 进行构建。在大多数情况下,一个项目对应于单一代码仓库,例如 <code>nixpkgs</code>。它类似于 Jenkins 中的项目定义。 |
| A cluster of Jobs which are all coming from a single input (like a git checkout), the first thing you will need to create. Every Job should be able to be built independently from another. Most of the time the project maps to a single repository like <code>nixpkgs</code>. It is comparable to the project definition in Jenkins.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Jobsets"></span> |
| ==== Jobsets ==== | | ==== 作业集 ==== |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 作业集是将要运行的一组作业(jobs)列表。通常,一个作业集会对应某个特定分支(如 master、staging、stable)。作业集由其输入(inputs)定义,并会在这些输入发生变化时触发。例如,当某个分支新增提交(commit)时。不同的作业集之间也可以存在依赖关系。 |
| A Jobset is a list of jobs which will be run. Often a jobset fits to a certain branch (master, staging, stable). A Jobset is defined by its inputs and will trigger if these inputs change. For example when a new commit onto a branch is added. Jobsets may depend on each other.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Job"></span> |
| ==== Job ==== | | ==== 作业 ==== |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 作为作业集的一部分构建的闭包(例如单个软件包、ISO 镜像或 tarball)。 |
| A closure which will be built as part of a job set (like a single package, iso image or tarball).
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Release_Set"></span> |
| ==== Release Set ==== | | ==== 发布集合 ==== |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 定义发行版中描述的所有作业。按照惯例,通常会使用名为<code>release.nix</code>的文件。关于其结构的详细说明,请参阅 [https://nixos.org/hydra/manual/#idm140737315920320 Hydra 手册中的 Build Recipes]。 |
| Defines all the jobs which are described in your release. By convention a file called<code>release.nix</code> is being used. See the [https://nixos.org/hydra/manual/#idm140737315920320 Hydra manual for Build Recipes] for a thorough description of the structure.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Evaluation"></span> |
| ==== Evaluation ==== | | ==== 评估 ==== |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 将 nix 代码解释为一组 <code>.drv 文件</code> 的过程。这些文件是所有相关输出的构建配方。你可以通过运行 <code>nix show-derivation nixpkgs.hello</code> 来检查这些文件。 |
| The process of interpreting nix code into a list of <code>.drv files</code>. These files are the build recipes for all related outputs. You can introspect these files by running <code>nix show-derivation nixpkgs.hello</code>.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Build"></span> |
| ==== Build ==== | | ==== 构建 ==== |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 作为发布集合的一部分而被触发的作业实例化过程。 |
| Instantiation of a Job which is being triggered by being part of the release set.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Known_Issues"></span> |
| == Known Issues == | | == 已知问题 == |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |
| Line 277: |
Line 205: |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | * 如果你看到 <code>error: unexpected end-of-file</code>,它可能意味着多种问题,其中一些包括: |
| * If you see <code>error: unexpected end-of-file</code> it can mean multiple things, some of them are: | |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | # 你的 Hydra 服务器与构建器之间的 Nix 版本不匹配 |
| # You have a miss-match between nix versions on the Hydra server and the builder | |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |
| Line 303: |
Line 227: |
| </syntaxHighlight> | | </syntaxHighlight> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Hydra_for_NixOS_releases"></span> |
| == Hydra for NixOS releases == | | == 用于 NixOS 发布的 Hydra == |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | Hydra 用于管理 Nix 项目的官方发布版本。该项目的 Hydra 服务器:https://hydra.nixos.org/ |
| Hydra is used for managing official Nix project releases. The project Hydra server: https://hydra.nixos.org/ | |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 一些适用于 Nix 项目的 Hydra 跟踪器: |
| Some Hydra trackers for Nix projects:
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * [https://hydra.nixos.org/project/nixpkgs Nixpkgs] | | * [https://hydra.nixos.org/project/nixpkgs Nixpkgs] |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| |
| * [https://hydra.nixos.org/project/nixos NixOS] | | * [https://hydra.nixos.org/project/nixos NixOS] |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Resources"></span> |
| == Resources == | | == 资源 == |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div lang="en" dir="ltr" class="mw-content-ltr"> |