Flakes/zh: Difference between revisions

FuzzyBot (talk | contribs)
Updating to match new version of source page
Tags: Mobile edit Mobile web edit
FuzzyBot (talk | contribs)
Updating to match new version of source page
Line 198: Line 198:
<code>inputs.hyprland.inputs.nixpkgs.follows = "nixpkgs";</code>
<code>inputs.hyprland.inputs.nixpkgs.follows = "nixpkgs";</code>


<div class="mw-translate-fuzzy">
使用大括号 (<code>{}</code>),我们可以缩短这些内容并将其放在一个表中。代码如下所示:
使用大括号 ({}),我们可以缩短这些内容并将其放在一个表中。代码如下所示:
</div>


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 235: Line 233:
* <code><store-path></code> 是 <code>/nix/store..</code> 的路径。
* <code><store-path></code> 是 <code>/nix/store..</code> 的路径。


<syntaxHighlight lang=nix>
<syntaxhighlight lang="nix">
{ self, ... }@inputs:
{ self, ... }@inputs:
{
{
Line 248: Line 246:
     type = "app";
     type = "app";
     program = "<store-path>";
     program = "<store-path>";
    meta = {description = "..."; inherit otherMetaAttrs; };
   };
   };
   # Executed by `nix run . -- <args?>`
   # Executed by `nix run . -- <args?>`
   apps."<system>".default = { type = "app"; program = "..."; };
   apps."<system>".default = { type = "app"; program = "..."; meta = {description = "..."; inherit otherMetaAttrs; }; };


   # Formatter (alejandra, nixfmt or nixpkgs-fmt)
   # Formatter (alejandra, nixfmt, treefmt-nix or nixpkgs-fmt)
   formatter."<system>" = derivation;
   formatter."<system>" = derivation;
   # Used for nixpkgs packages, also accessible via `nix build .#<name>`
   # Used for nixpkgs packages, also accessible via `nix build .#<name>`
Line 281: Line 280:
   templates.default = { path = "<store-path>"; description = ""; };
   templates.default = { path = "<store-path>"; description = ""; };
}
}
</syntaxHighlight>
</syntaxhighlight>


您还可以定义其他任意属性,但以上这些是 Nix 已知的输出。
您还可以定义其他任意属性,但以上这些是 Nix 已知的输出。
Line 461: Line 460:
=== 指南 ===
=== 指南 ===


* [https://jade.fyi/blog/flakes-arent-real/ Flakes 幻象,亦非洪水猛兽] (Jade Lovelace, 2024)
* [https://jade.fyi/blog/flakes-arent-real/ Flakes 并非幻象,亦非洪水猛兽] (Jade Lovelace, 2024)


* [https://github.com/ryan4yin/nixos-and-flakes-book NixOS & Flakes Book](Ryan4yin, 2023) - 🛠️ ❤️ 一本非官方的 NixOS & Flakes 新手入门书籍。
* [https://github.com/ryan4yin/nixos-and-flakes-book NixOS & Flakes Book](Ryan4yin, 2023) - 🛠️ ❤️ 一本非官方的 NixOS & Flakes 新手入门书籍。