Flakes/zh: Difference between revisions

Weijia (talk | contribs)
Created page with "=== 如何在 git 中添加一个本地文件但不将其包含在提交中 ==="
Tags: Mobile edit Mobile web edit
Weijia (talk | contribs)
Created page with "当 git 文件夹存在时,flake 将仅复制在 git 中添加的文件,以最大限度地提高可复现性(因此,如果您忘记在代码库中添加本地文件,则在尝试编译时会直接出错)。但是,有时出于开发目的您可能需要创建一个备用的 flake 文件,例如包含您首选编辑器的配置,如[https://discourse.nixos.org/t/local-personal-development-tools-with-flakes/22714/8 此处所述],这种情况下当然无..."
Line 417: Line 417:
=== 如何在 git 中添加一个本地文件但不将其包含在提交中 ===
=== 如何在 git 中添加一个本地文件但不将其包含在提交中 ===


<div lang="en" dir="ltr" class="mw-content-ltr">
[[git]] 文件夹存在时,flake 将仅复制在 git 中添加的文件,以最大限度地提高可复现性(因此,如果您忘记在代码库中添加本地文件,则在尝试编译时会直接出错)。但是,有时出于开发目的您可能需要创建一个备用的 flake 文件,例如包含您首选编辑器的配置,如[https://discourse.nixos.org/t/local-personal-development-tools-with-flakes/22714/8 此处所述],这种情况下当然无需提交此文件,因为它只包含您自己首选的工具。在上述情况下,您可以执行以下操作(例如,创建了一个名为  <code>extra/flake.nix</code> 的文件):
When a [[git]] folder exists, flake will only copy files added in git to maximize reproducibility (this way if you forgot to add a local file in your repo, you will directly get an error when you try to compile it). However, for development purpose you may want to create an alternative flake file, for instance containing configuration for your preferred editors as described [https://discourse.nixos.org/t/local-personal-development-tools-with-flakes/22714/8 here]… of course without committing this file since it contains only your own preferred tools. You can do so by doing something like that (say for a file called <code>extra/flake.nix</code>):
</div>


<syntaxHighlight>
<syntaxHighlight>