mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2024-11-24 17:13:12 +01:00
fix: nix store gc & nix-collect-garbage
This commit is contained in:
parent
302f9425c8
commit
68a8e022a1
@ -43,7 +43,6 @@ clean:
|
|||||||
|
|
||||||
gc:
|
gc:
|
||||||
# garbage collect all unused nix store entries
|
# garbage collect all unused nix store entries
|
||||||
sudo nix store gc --debug
|
|
||||||
sudo nix-collect-garbage --delete-old
|
sudo nix-collect-garbage --delete-old
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
@ -22,6 +22,8 @@ Overall, I strongly recommend everyone to use Flakes, especially since this book
|
|||||||
|
|
||||||
## Nix Flakes and Classic Nix
|
## Nix Flakes and Classic Nix
|
||||||
|
|
||||||
|
> Currently the New CLI is strongly bound to the Flakes feature, so I will use the term "Flakes" to refer to the New CLI & Flakes feature in this book.
|
||||||
|
|
||||||
Since the `nix-command` and `flakes` features are still experimental, the official documentation lacks detailed coverage, and the community's documentation on them is also scattered. From the perspective of reproducibility, ease of management, and maintenance, the classic Nix package structure and CLI are no longer recommended. Therefore, I will not delve into the usage of classic Nix. Beginners are advised to start with `nix-command` and `flakes` while disregarding any content related to classic Nix.
|
Since the `nix-command` and `flakes` features are still experimental, the official documentation lacks detailed coverage, and the community's documentation on them is also scattered. From the perspective of reproducibility, ease of management, and maintenance, the classic Nix package structure and CLI are no longer recommended. Therefore, I will not delve into the usage of classic Nix. Beginners are advised to start with `nix-command` and `flakes` while disregarding any content related to classic Nix.
|
||||||
|
|
||||||
The following are classic Nix commands and associated concepts that are no longer necessary after enabling `nix-command` and `flakes`. When searching for information, you can safely ignore them:
|
The following are classic Nix commands and associated concepts that are no longer necessary after enabling `nix-command` and `flakes`. When searching for information, you can safely ignore them:
|
||||||
@ -36,7 +38,7 @@ The following are classic Nix commands and associated concepts that are no longe
|
|||||||
4. `nix-build`: `nix-build` builds Nix packages and places the build results in `/nix/store`, but it does not record them in Nix's declarative configuration.
|
4. `nix-build`: `nix-build` builds Nix packages and places the build results in `/nix/store`, but it does not record them in Nix's declarative configuration.
|
||||||
1. In Flakes, `nix-build` is replaced by `nix build`.
|
1. In Flakes, `nix-build` is replaced by `nix build`.
|
||||||
5. `nix-collect-garbage`: Garbage collection command used to clean up unused Store Objects in `/nix/store`.
|
5. `nix-collect-garbage`: Garbage collection command used to clean up unused Store Objects in `/nix/store`.
|
||||||
1. In Nix Flakes, the corresponding command is `nix store gc --debug`.
|
1. There is a smimilar command in Flakes, `nix store gc`, but it do not clean the profile generations.
|
||||||
6. And other less commonly used commands are not listed here.
|
6. And other less commonly used commands are not listed here.
|
||||||
1. You can refer to the detailed command comparison list in [Try to explain nix commands](https://qiita.com/Sumi-Sumi/items/6de9ee7aab10bc0dbead?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en).
|
1. You can refer to the detailed command comparison list in [Try to explain nix commands](https://qiita.com/Sumi-Sumi/items/6de9ee7aab10bc0dbead?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en).
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ Flakes 带来的好处是显而易见的,整个 NixOS 社区都很喜欢它,
|
|||||||
|
|
||||||
## Flakes 与传统的 Nix
|
## Flakes 与传统的 Nix
|
||||||
|
|
||||||
|
|
||||||
|
> 当前 New CLI 与 Flakes 特性是强绑定的(虽然现在已经有明确的拆分计划),因此在本书中我会使用 Flakes 来指代 New CLI 与 Flakes 两项特性。
|
||||||
|
|
||||||
Nix 于 2020 年推出了 `nix-command` & `flakes` 两个新特性,它们提供了全新的命令行工具、标准的 Nix 包结构定义、类似 cargo/npm 的 `flake.lock` 版本锁文件等等。这两个特性极大地增强了 Nix 的能力,因此虽然至今(2023/5/5)它们仍然是实验性特性,但是已经被 Nix 社区广泛使用。
|
Nix 于 2020 年推出了 `nix-command` & `flakes` 两个新特性,它们提供了全新的命令行工具、标准的 Nix 包结构定义、类似 cargo/npm 的 `flake.lock` 版本锁文件等等。这两个特性极大地增强了 Nix 的能力,因此虽然至今(2023/5/5)它们仍然是实验性特性,但是已经被 Nix 社区广泛使用。
|
||||||
|
|
||||||
但由于 `nix-command` & `flakes` 仍然是实验性特性,官方文档基本不包含任何介绍它们的内容,同时社区关于 Flakes 的文档也相当分散且不完整。
|
但由于 `nix-command` & `flakes` 仍然是实验性特性,官方文档基本不包含任何介绍它们的内容,同时社区关于 Flakes 的文档也相当分散且不完整。
|
||||||
@ -41,7 +44,7 @@ Nix 于 2020 年推出了 `nix-command` & `flakes` 两个新特性,它们提
|
|||||||
4. `nix-build`: 用于构建 Nix 包,它会将构建结果放到 `/nix/store` 路径下,但是不会记录到 Nix 的声明式配置中。
|
4. `nix-build`: 用于构建 Nix 包,它会将构建结果放到 `/nix/store` 路径下,但是不会记录到 Nix 的声明式配置中。
|
||||||
1. 在 Nix Flakes 中对应的命令为 `nix build`
|
1. 在 Nix Flakes 中对应的命令为 `nix build`
|
||||||
5. `nix-collect-garbage`: 垃圾回收指令,用于清理 `/nix/store` 中未被使用的 Store Objects.
|
5. `nix-collect-garbage`: 垃圾回收指令,用于清理 `/nix/store` 中未被使用的 Store Objects.
|
||||||
1. 在 Nix Flakes 中对应的命令为 `nix store gc --debug`.
|
1. 在 Nix Flakes 中有个相似的指令 `nix store gc --debug`,但它不会清理 profile 生成的历史版本,因此此命令暂无替代。
|
||||||
6. 以及其他使用地较少的命令,就不一一列出了.
|
6. 以及其他使用地较少的命令,就不一一列出了.
|
||||||
1. 详细的命令对比列表可以看看 [Try to explain nix commands](https://qiita-com.translate.goog/Sumi-Sumi/items/6de9ee7aab10bc0dbead?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en)
|
1. 详细的命令对比列表可以看看 [Try to explain nix commands](https://qiita-com.translate.goog/Sumi-Sumi/items/6de9ee7aab10bc0dbead?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user