mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2024-11-21 23:53:12 +01:00
fix: fix typos (#123)
This commit is contained in:
parent
487860b43a
commit
a9f4bb9233
@ -72,7 +72,7 @@ In your system's `flake.nix`, add a new outputs named `colmena`. A simple exampl
|
|||||||
meta = {
|
meta = {
|
||||||
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
|
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
|
|
||||||
# This parameter functions similarly to `sepcialArgs` in `nixosConfigurations.xxx`,
|
# This parameter functions similarly to `specialArgs` in `nixosConfigurations.xxx`,
|
||||||
# used for passing custom arguments to all submodules.
|
# used for passing custom arguments to all submodules.
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit nixpkgs;
|
inherit nixpkgs;
|
||||||
|
@ -211,7 +211,7 @@ So how to use this method in Flakes? The example `flake.nix` is as follows:
|
|||||||
nixpkgs.overlays = [ (self: super: { gcc = self.gcc12; }) ];
|
nixpkgs.overlays = [ (self: super: { gcc = self.gcc12; }) ];
|
||||||
}
|
}
|
||||||
|
|
||||||
# other moduels ......
|
# other modules ......
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -261,7 +261,7 @@ To avoid this problem, a better way is to create a new `pkgs` instance, and only
|
|||||||
environment.systemPackages = [ pkgs-gcc12.hello ];
|
environment.systemPackages = [ pkgs-gcc12.hello ];
|
||||||
})
|
})
|
||||||
|
|
||||||
# other moduels ......
|
# other modules ......
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -138,7 +138,7 @@ Here is a `flake.nix` that defines a development environment with Node.js 18 ins
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Create an empty folder, save the above configuration as `flake.nix`, and then execute `nix develop` (or more precisely, you can use `nix develop .#default`), the current version of nodejs will be outputed, and now you can use `node` `pnpm` `yarn` seamlessly.
|
Create an empty folder, save the above configuration as `flake.nix`, and then execute `nix develop` (or more precisely, you can use `nix develop .#default`), the current version of nodejs will be outputted, and now you can use `node` `pnpm` `yarn` seamlessly.
|
||||||
|
|
||||||
|
|
||||||
## Using zsh/fish/... instead of bash
|
## Using zsh/fish/... instead of bash
|
||||||
|
@ -71,8 +71,8 @@ this will cause the following error:
|
|||||||
```bash
|
```bash
|
||||||
error: builder for '/nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv' failed with exit code 25;
|
error: builder for '/nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv' failed with exit code 25;
|
||||||
last 1 log lines:
|
last 1 log lines:
|
||||||
> error: collision between `/nix/store/kvq0gvz6jwggarrcn9a8ramsfhyh1h9d-lldb-14.0.6/lib/python3.11/site-packages/six.py' a
|
> error: collision between `/nix/store/kvq0gvz6jwggarrcn9a8ramsfhyh1h9d-lldb-14.0.6/lib/python3.11/site-packages/six.py'
|
||||||
nd `/nix/store/370s8inz4fc9k9lqk4qzj5vyr60q166w-python3-3.11.6-env/lib/python3.11/site-packages/six.py'
|
and `/nix/store/370s8inz4fc9k9lqk4qzj5vyr60q166w-python3-3.11.6-env/lib/python3.11/site-packages/six.py'
|
||||||
For full logs, run 'nix log /nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv'.
|
For full logs, run 'nix log /nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv'.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ Here's an example of how you can add multiple nixpkgs inputs, each using a diffe
|
|||||||
# the outer scope recursively
|
# the outer scope recursively
|
||||||
inherit system;
|
inherit system;
|
||||||
# To use Chrome, we need to allow the
|
# To use Chrome, we need to allow the
|
||||||
# installation of non-free softwares.
|
# installation of non-free software.
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
};
|
};
|
||||||
pkgs-fd40cef8d = import nixpkgs-fd40cef8d {
|
pkgs-fd40cef8d = import nixpkgs-fd40cef8d {
|
||||||
|
@ -50,7 +50,7 @@ According to the official [Home Manager Manual](https://nix-community.github.io/
|
|||||||
# utils
|
# utils
|
||||||
ripgrep # recursively searches directories for a regex pattern
|
ripgrep # recursively searches directories for a regex pattern
|
||||||
jq # A lightweight and flexible command-line JSON processor
|
jq # A lightweight and flexible command-line JSON processor
|
||||||
yq-go # yaml processer https://github.com/mikefarah/yq
|
yq-go # yaml processor https://github.com/mikefarah/yq
|
||||||
eza # A modern replacement for ‘ls’
|
eza # A modern replacement for ‘ls’
|
||||||
fzf # A command-line fuzzy finder
|
fzf # A command-line fuzzy finder
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ In the previous section, we learned about overriding derivations by `pkgs.xxx.ov
|
|||||||
However, this approach will generate a new derivation and doesn't modify the original derivation in `pkgs` instance.
|
However, this approach will generate a new derivation and doesn't modify the original derivation in `pkgs` instance.
|
||||||
If the derivation you want to override is also used by other Nix packages, they will still use the unmodified derivation.
|
If the derivation you want to override is also used by other Nix packages, they will still use the unmodified derivation.
|
||||||
|
|
||||||
To globally modify derivations in the detault nixpkgs instance, Nix provides a feature called "overlays".
|
To globally modify derivations in the default nixpkgs instance, Nix provides a feature called "overlays".
|
||||||
|
|
||||||
In traditional Nix environments, overlays can be configured globally using the `~/.config/nixpkgs/overlays.nix` or `~/.config/nixpkgs/overlays/*.nix` files.
|
In traditional Nix environments, overlays can be configured globally using the `~/.config/nixpkgs/overlays.nix` or `~/.config/nixpkgs/overlays/*.nix` files.
|
||||||
However, with Flakes feature, to ensure system reproducibility, overlays cannot rely on configurations outside of the Git repository.
|
However, with Flakes feature, to ensure system reproducibility, overlays cannot rely on configurations outside of the Git repository.
|
||||||
|
@ -72,7 +72,7 @@ ssh-add ~/.ssh/your-private-key
|
|||||||
meta = {
|
meta = {
|
||||||
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
|
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
|
|
||||||
# 这个参数的功能与 `nixosConfigurations.xxx` 中的 `sepcialArgs` 一致,
|
# 这个参数的功能与 `nixosConfigurations.xxx` 中的 `specialArgs` 一致,
|
||||||
# 都是用于传递自定义参数到所有子模块。
|
# 都是用于传递自定义参数到所有子模块。
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit nixpkgs;
|
inherit nixpkgs;
|
||||||
|
@ -211,7 +211,7 @@ nix-repl> pkgs.pkgsCross.riscv64.stdenv.cc
|
|||||||
nixpkgs.overlays = [ (self: super: { gcc = self.gcc12; }) ];
|
nixpkgs.overlays = [ (self: super: { gcc = self.gcc12; }) ];
|
||||||
}
|
}
|
||||||
|
|
||||||
# other moduels ......
|
# other modules ......
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -261,7 +261,7 @@ nix-repl> pkgs.pkgsCross.riscv64.stdenv.cc
|
|||||||
environment.systemPackages = [ pkgs-gcc12.hello ];
|
environment.systemPackages = [ pkgs-gcc12.hello ];
|
||||||
})
|
})
|
||||||
|
|
||||||
# other moduels ......
|
# other modules ......
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -77,8 +77,8 @@ Nix 与以 Docker 为代表的容器技术的应用场景也存在一定重合
|
|||||||
```bash
|
```bash
|
||||||
error: builder for '/nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv' failed with exit code 25;
|
error: builder for '/nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv' failed with exit code 25;
|
||||||
last 1 log lines:
|
last 1 log lines:
|
||||||
> error: collision between `/nix/store/kvq0gvz6jwggarrcn9a8ramsfhyh1h9d-lldb-14.0.6/lib/python3.11/site-packages/six.py' a
|
> error: collision between `/nix/store/kvq0gvz6jwggarrcn9a8ramsfhyh1h9d-lldb-14.0.6/lib/python3.11/site-packages/six.py'
|
||||||
nd `/nix/store/370s8inz4fc9k9lqk4qzj5vyr60q166w-python3-3.11.6-env/lib/python3.11/site-packages/six.py'
|
and `/nix/store/370s8inz4fc9k9lqk4qzj5vyr60q166w-python3-3.11.6-env/lib/python3.11/site-packages/six.py'
|
||||||
For full logs, run 'nix log /nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv'.
|
For full logs, run 'nix log /nix/store/n3scj3s7v9jsb6y3v0fhndw35a9hdbs6-home-manager-path.drv'.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ Flakes 带来的好处是显而易见的,整个 NixOS 社区都很喜欢它,
|
|||||||
- [Why are flakes still experimental? - NixOS Discourse](https://discourse.nixos.org/t/why-are-flakes-still-experimental/29317): 最近的一次关于 Flakes 稳定性的讨论,可以看到大家的疑惑,以及社区对 Flakes 的态度。
|
- [Why are flakes still experimental? - NixOS Discourse](https://discourse.nixos.org/t/why-are-flakes-still-experimental/29317): 最近的一次关于 Flakes 稳定性的讨论,可以看到大家的疑惑,以及社区对 Flakes 的态度。
|
||||||
- [Flakes are such an obviously good thing - Graham Christensen](https://grahamc.com/blog/flakes-are-an-obviously-good-thing/): NixOS 社区成员的文章,记录了他对 Flakes 的看法,以及对社区当初添加 Flakes 特性时的不当举措的懊悔。
|
- [Flakes are such an obviously good thing - Graham Christensen](https://grahamc.com/blog/flakes-are-an-obviously-good-thing/): NixOS 社区成员的文章,记录了他对 Flakes 的看法,以及对社区当初添加 Flakes 特性时的不当举措的懊悔。
|
||||||
- [ teaching Nix 3 CLI and Flakes #281 - nix.dev](https://github.com/NixOS/nix.dev/issues/281): 社区关于是否应该在 NixOS 官方文档中介绍 Flakes 的讨论,当前结论是官方文档不应该推广使用 unstable 功能。
|
- [ teaching Nix 3 CLI and Flakes #281 - nix.dev](https://github.com/NixOS/nix.dev/issues/281): 社区关于是否应该在 NixOS 官方文档中介绍 Flakes 的讨论,当前结论是官方文档不应该推广使用 unstable 功能。
|
||||||
- [Draft: 1 year roadmap - NixOS Foundation](https://nixos-foundation.notion.site/1-year-roadmap-0dc5c2ec265a477ea65c549cd5e568a9): NixOS Fundation 的一份 Roadmap,其中提到了 Flakes 的计划:`Stabilize flakes and release Nix 3.0. Flakes are widely used (there are more GitHub repos being created with a flake.nix than a default.nix) but they’re still marked as experimental, which is not a good situation. The same applies to the new nix CLI.`
|
- [Draft: 1 year roadmap - NixOS Foundation](https://nixos-foundation.notion.site/1-year-roadmap-0dc5c2ec265a477ea65c549cd5e568a9): NixOS Foundation 的一份 Roadmap,其中提到了 Flakes 的计划:`Stabilize flakes and release Nix 3.0. Flakes are widely used (there are more GitHub repos being created with a flake.nix than a default.nix) but they’re still marked as experimental, which is not a good situation. The same applies to the new nix CLI.`
|
||||||
|
|
||||||
读完上述内容后,个人猜测,**Flakes 有可能(仅是可能)会在未来两年内成为稳定特性**。
|
读完上述内容后,个人猜测,**Flakes 有可能(仅是可能)会在未来两年内成为稳定特性**。
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ sudo nixos-rebuild switch --flake github:owner/repo#your-hostname
|
|||||||
|
|
||||||
上面的描述可能有点绕,我们还是结合本节中使用的 `flake.nix` 示例来看看这个过程。
|
上面的描述可能有点绕,我们还是结合本节中使用的 `flake.nix` 示例来看看这个过程。
|
||||||
我们的 `flake.nix` 声明了 `inputs.nixpkgs` 这个依赖项,因此
|
我们的 `flake.nix` 声明了 `inputs.nixpkgs` 这个依赖项,因此
|
||||||
[nixpkgs/flake.nix] 会在我们执行 `sudo nixos-rebuild swtich` 这个命令时被求值。
|
[nixpkgs/flake.nix] 会在我们执行 `sudo nixos-rebuild switch` 这个命令时被求值。
|
||||||
从 Nixpkgs 仓库的源码中能看到它的 flake outputs 定义中有返回 `lib` 这个属性,我们的例子中就使用了 `lib` 属性中的 `nixosSystem` 这个函数来配置我们的 NixOS 系统:
|
从 Nixpkgs 仓库的源码中能看到它的 flake outputs 定义中有返回 `lib` 这个属性,我们的例子中就使用了 `lib` 属性中的 `nixosSystem` 这个函数来配置我们的 NixOS 系统:
|
||||||
|
|
||||||
```nix{8-13}
|
```nix{8-13}
|
||||||
@ -305,7 +305,7 @@ NixOS 社区比较推荐优先使用 `_module.args` 这个 options,仅在无
|
|||||||
|
|
||||||
# 将所有 inputs 参数设为所有子模块的特殊参数,
|
# 将所有 inputs 参数设为所有子模块的特殊参数,
|
||||||
# 这样就能直接在子模块中使用 inputs 中的所有依赖项了
|
# 这样就能直接在子模块中使用 inputs 中的所有依赖项了
|
||||||
specialArgs = { inheirt inputs;};
|
specialArgs = { inherit inputs;};
|
||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
];
|
];
|
||||||
@ -376,7 +376,7 @@ NixOS 社区比较推荐优先使用 `_module.args` 这个 options,仅在无
|
|||||||
outputs = inputs@{ self, nixpkgs, ... }: {
|
outputs = inputs@{ self, nixpkgs, ... }: {
|
||||||
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
|
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
specialArgs = { inheirt inputs;};
|
specialArgs = { inherit inputs;};
|
||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ sudo nix-collect-garbage --delete-old
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Optimise storage
|
# Optimise storage
|
||||||
# you can alse optimise the store manually via:
|
# you can also optimise the store manually via:
|
||||||
# nix-store --optimise
|
# nix-store --optimise
|
||||||
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
|
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
|
||||||
nix.settings.auto-optimise-store = true;
|
nix.settings.auto-optimise-store = true;
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
# utils
|
# utils
|
||||||
ripgrep # recursively searches directories for a regex pattern
|
ripgrep # recursively searches directories for a regex pattern
|
||||||
jq # A lightweight and flexible command-line JSON processor
|
jq # A lightweight and flexible command-line JSON processor
|
||||||
yq-go # yaml processer https://github.com/mikefarah/yq
|
yq-go # yaml processor https://github.com/mikefarah/yq
|
||||||
eza # A modern replacement for ‘ls’
|
eza # A modern replacement for ‘ls’
|
||||||
fzf # A command-line fuzzy finder
|
fzf # A command-line fuzzy finder
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# pkgs.callPackage
|
# pkgs.callPackage
|
||||||
|
|
||||||
`pkgs.callPackage` 被用于参数化构建 Nix 包,为了理解它的用处,我们首先考虑下不使用 `pkgs.callPakcage` 的情况下,我们要如何定义一个 Nix 包(也就是 Derivation)。
|
`pkgs.callPackage` 被用于参数化构建 Nix 包,为了理解它的用处,我们首先考虑下不使用 `pkgs.callPackage` 的情况下,我们要如何定义一个 Nix 包(也就是 Derivation)。
|
||||||
|
|
||||||
## 1. 不使用 `pkgs.callPackage` 的情况
|
## 1. 不使用 `pkgs.callPackage` 的情况
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user