Skip to content

Commit c07c5a6

Browse files
committed
docs: flake inputs
1 parent 0865921 commit c07c5a6

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

docs/en/other-usage-of-flakes/inputs.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
The `inputs` section in `flake.nix` is an attribute set used to specify the dependencies
44
of the current flake. There are various types of inputs, as shown in the examples below:
55

6+
> See Offical docs for details - [Flakes Inputs - Nix Manual].
7+
68
```nix
79
{
810
inputs = {
@@ -18,8 +20,10 @@ of the current flake. There are various types of inputs, as shown in the example
1820
# Git URL with submodules, applicable to any Git repository using the https/ssh protocol.
1921
git-example-submodule.url = "git+https://git.somehost.tld/user/path?submodules=1";
2022
# Archive File URL, needed in case your input use LFS.
21-
# Regular git input doesn't support LFS yet.
23+
# Regular git input doesn't support LFS before nix 2.27
2224
git-example-lfs.url = "https://codeberg.org/solver-orgz/treedome/archive/master.tar.gz";
25+
# Starting from nix 2.27, you can use the url like below to enable git lfs on flake input
26+
treedome.url = "git+https://codeberg.org/solver-orgz/treedome?ref=master&lfs=1";
2327
# Similar to fetching a Git repository, but using the ssh protocol
2428
# with key authentication. Also uses the shallow=1 parameter
2529
# to avoid copying the .git directory.
@@ -62,3 +66,9 @@ of the current flake. There are various types of inputs, as shown in the example
6266
outputs = { self, ... }@inputs: { ... };
6367
}
6468
```
69+
70+
## 参考
71+
72+
- [Flakes Inputs - Nix Manual]
73+
74+
[Flakes Inputs - Nix Manual]: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references

docs/zh/other-usage-of-flakes/inputs.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@
33
`flake.nix` 中的 `inputs` 是一个 attribute set,用来指定当前 Flake 的依赖,inputs 有很多种
44
类型,举例如下:
55

6+
> 详细的例子参见官方文档 [Flakes Inputs - Nix Manual]
7+
68
```nix
79
{
810
inputs = {
911
# 以 GitHub 仓库为数据源,指定使用 master 分支,这是最常见的 input 格式
1012
nixpkgs.url = "github:Mic92/nixpkgs/master";
1113
# Git URL,可用于任何基于 https/ssh 协议的 Git 仓库
1214
git-example.url = "git+https://git.somehost.tld/user/path?ref=branch";
13-
# 同样是拉取 Git 仓库,但使用 ssh 协议 + 密钥认证,同时使用了 shallow=1 参数避免复制 .git
14-
ssh-git-example.url = "git+ssh://[email protected]/ryan4yin/nix-secrets.git?shallow=1";
15+
# Git URL by tag, applicable to any Git repository using the https/ssh protocol.
16+
git-example-tag.url = "git+https://git.somehost.tld/user/path?tag=x.y.x";
17+
# Github URL by pull request.
18+
git-pr.url = "github:NixOS/nixpkgs?ref=pull/349351/head";
19+
# Git URL with submodules, applicable to any Git repository using the https/ssh protocol.
20+
git-example-submodule.url = "git+https://git.somehost.tld/user/path?submodules=1";
1521
# Archive File URL, needed in case your input use LFS.
16-
# Regular git input doesn't support LFS yet.
22+
# Regular git input doesn't support LFS before nix 2.27
1723
git-example-lfs.url = "https://codeberg.org/solver-orgz/treedome/archive/master.tar.gz";
24+
# Starting from nix 2.27, you can use the url like below to enable git lfs on flake input
25+
treedome.url = "git+https://codeberg.org/solver-orgz/treedome?ref=master&lfs=1";
26+
# 同样是拉取 Git 仓库,但使用 ssh 协议 + 密钥认证,同时使用了 shallow=1 参数避免复制 .git
27+
ssh-git-example.url = "git+ssh://[email protected]/ryan4yin/nix-secrets.git?shallow=1";
1828
# 当然也可以直接依赖本地的 git 仓库
1929
git-directory-example.url = "git+file:/path/to/repo?shallow=1";
2030
# 使用 `dir` 参数指定某个子目录
@@ -50,3 +60,10 @@
5060
outputs = { self, ... }@inputs: { ... };
5161
}
5262
```
63+
64+
65+
## 参考
66+
67+
- [Flakes Inputs - Nix Manual]
68+
69+
[Flakes Inputs - Nix Manual]: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references

0 commit comments

Comments
 (0)