diff --git a/docs/nixos-with-flakes/introduction-to-flakes.md b/docs/nixos-with-flakes/introduction-to-flakes.md index bc52287..44eb6b7 100644 --- a/docs/nixos-with-flakes/introduction-to-flakes.md +++ b/docs/nixos-with-flakes/introduction-to-flakes.md @@ -4,6 +4,14 @@ The flakes experimental feature is a major development for Nix, it introduces a Flakes is one of the most significant changes the nix project has ever seen.[^2] +In simple terms, if you've worked with some JavaScript/Go/Rust/Python, you should be familiar with files like `package.json`/`go.mod`/`Cargo.toml`/`pyproject.toml`. In these programming languages, these files are used to describe the dependencies between software packages and how to build projects. + +Similarly, the package managers in these programming languages also use files like `package-lock.json`/`go.sum`/`Cargo.lock`/`poetry.lock` to lock the versions of dependencies, ensuring the reproducibility of projects. + +Flakes borrow ideas from these package managers to enhance the reproducibility, composability, and usability of the Nix ecosystem. +Flakes introduce `flake.nix`, similar to `package.json`, to describe the dependencies between Nix packages and how to build projects. +Additionally, it provides `flake.lock`, akin to `package-lock.json`, to lock the versions of dependencies, ensuring project reproducibility. + ## A Word of Caution about Flakes The benefits of Flakes are evident, and the entire NixOS community has embraced it wholeheartedly. Currently, more than half of the users utilize Flakes[^3], providing assurance that Flakes will not be deprecated. diff --git a/docs/zh/nixos-with-flakes/introduction-to-flakes.md b/docs/zh/nixos-with-flakes/introduction-to-flakes.md index d072a4b..afc0688 100644 --- a/docs/zh/nixos-with-flakes/introduction-to-flakes.md +++ b/docs/zh/nixos-with-flakes/introduction-to-flakes.md @@ -5,6 +5,15 @@ Flakes 实验特性是 Nix 项目的一项重大进展,它引入了一种管 Flakes 特性是 Nix 项目中最有意义的变化之一。[^2] +简单的说,如果你写过点 JavaScript/Go/Rust/Python,那你应该对 `package.json`/`go.mod`/`Cargo.toml`/`pyproject.toml` 这些文件不陌生, +在这些编程语言中,这些文件用来描述软件包之间的依赖关系,以及如何构建项目。 +同样的,这些编程语言的包管理器还通过 `package-lock.json`/`go.sum`/`Cargo.lock`/`poetry.lock` 这些文件来锁定依赖的版本,以保证项目的可复现性。 + +Flakes 就是从上述这类编程语言的包管理器中借鉴了一些思想,以提高 Nix 生态系统中的可复现性、可组合性和可用性。 +Flakes 提供了 `flake.nix`,它类似 `package.json`,用来描述 Nix 包之间的依赖关系,以及如何构建项目。 +同时它还提供了 `flake.lock`,这是一个类似 `package-lock.json` 的文件,用来锁定依赖的版本,以保证项目的可复现性。 + + ## 注意事项 Flakes 带来的好处是显而易见的,整个 NixOS 社区都很喜欢它,目前超过半数的用户已经在大量使用 Flakes[^3],因此我们可以相当确定 Flakes 不会被废弃。