mirror of
https://github.com/ryan4yin/nixos-and-flakes-book
synced 2024-11-23 04:33:08 +00:00
feat: Leveraging Features from Other Flakes Packages
This commit is contained in:
parent
40b5fc05ee
commit
ef3099d1ee
2 changed files with 17 additions and 0 deletions
|
@ -248,3 +248,13 @@ After that, you can start the Helix editor by running the `hx` command.
|
|||
|
||||
> If your system's hostname is not `nixos-test`, you need to modify the name of `nixosConfigurations` in `flake.nix`, or use `--flake /etc/nixos#nixos-test` to specify the configuration name.
|
||||
|
||||
|
||||
## Leveraging Features from Other Flakes Packages
|
||||
|
||||
In fact, this is the primary functionality of Flakes — a Flake can depend on other Flakes, allowing it to utilize the features they provide. It's akin to how we incorporate functionalities from other libraries when writing programs in TypeScript, Go, Rust, and other programming languages.
|
||||
|
||||
The example above, using the latest version from the official Helix Flake, illustrates this functionality. More use cases will be discussed later, and here are a few examples referenced for future mention:
|
||||
|
||||
- [Getting Started with Home Manager](./start-using-home-manager.md): This introduces the community's Home-Manager as a dependency, enabling direct utilization of the features provided by this Flake.
|
||||
- [Downgrading or Upgrading Packages](./downgrade-or-upgrade-packages.md): Here, different versions of Nixpkgs are introduced as dependencies, allowing for flexible selection of packages from various versions of Nixpkgs.
|
||||
|
||||
|
|
|
@ -229,5 +229,12 @@ cat flake.nix
|
|||
|
||||
> 如果你的系统 Hostname 不是 `nixos-test`,你需要在 `flake.nix` 中修改 `nixosConfigurations` 的名称,或者使用 `--flake /etc/nixos#nixos-test` 来指定配置名称。
|
||||
|
||||
## 使用其他 Flakes 包提供的功能
|
||||
|
||||
其实这才是 Flakes 最主要的功能,一个 Flake 可以依赖其他 Flakes,从而使用它们提供的功能——就如同我们在写 TypeScript/Go/Rust 等程序时使用其他 Library 提供的功能一样。
|
||||
|
||||
上面使用 Helix 的官方 Flake 中提供的最新版本就是一个例子,其他更多的用例会在后面提到,这里引用几个后面会讲的例子:
|
||||
|
||||
- [Getting Started with Home Manager](./start-using-home-manager.md): 这里引入了社区的 Home-Manager 作为依赖项,从而能直接使用该 Flake 提供的功能。
|
||||
- [Downgrading or Upgrading Packages](./downgrade-or-upgrade-packages.md): 这里引入了不同版本的 Nixpkgs 作为依赖项,从而能很灵活地选用不同版本的 Nixpkgs 中的包。
|
||||
|
||||
|
|
Loading…
Reference in a new issue