mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2025-02-16 18:30:55 +01:00
fix: code box style
This commit is contained in:
parent
8f0b8d6cb2
commit
3ec5856073
@ -24,7 +24,7 @@ However, as Flakes is still an experimental feature, it is not enabled by defaul
|
|||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
# Flakes use Git to pull dependencies from data sources, so Git must be installed first
|
# Flakes use Git to pull dependencies from data sources
|
||||||
git
|
git
|
||||||
vim
|
vim
|
||||||
wget
|
wget
|
||||||
@ -143,9 +143,12 @@ Note that the copied template cannot be used directly. You need to modify it to
|
|||||||
# this parameter is rarely used,
|
# this parameter is rarely used,
|
||||||
# you can ignore it for now.
|
# you can ignore it for now.
|
||||||
#
|
#
|
||||||
# The default parameters mentioned above are automatically generated by Nixpkgs.
|
# The default parameters mentioned above are automatically
|
||||||
# However, if you need to pass other non-default parameters to the submodules,
|
# generated by Nixpkgs.
|
||||||
# you'll have to manually configure these parameters using `specialArgs`.
|
# However, if you need to pass other non-default parameters
|
||||||
|
# to the submodules,
|
||||||
|
# you'll have to manually configure these parameters using
|
||||||
|
# `specialArgs`.
|
||||||
# you must use `specialArgs` by uncomment the following line:
|
# you must use `specialArgs` by uncomment the following line:
|
||||||
#
|
#
|
||||||
# specialArgs = {...}; # pass custom arguments into all sub module.
|
# specialArgs = {...}; # pass custom arguments into all sub module.
|
||||||
@ -200,7 +203,8 @@ First, we need to add Helix as an input in `flake.nix`:
|
|||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
|
||||||
# Set all input parameters as specialArgs of all sub-modules
|
# Set all input parameters as specialArgs of all sub-modules
|
||||||
# so that we can use the `helix`(an attribute in inputs) in sub-modules directly.
|
# so that we can use the `helix`(an attribute in inputs) in
|
||||||
|
# sub-modules directly.
|
||||||
specialArgs = inputs;
|
specialArgs = inputs;
|
||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
@ -294,7 +298,8 @@ This is a security limitation of Nix, where only trusted users can properly use
|
|||||||
{
|
{
|
||||||
# ... (other configurations omitted)
|
# ... (other configurations omitted)
|
||||||
|
|
||||||
nix.settings.trusted-users = [ "ryan" ]; # Add your own username to the trusted list
|
# Add your own username to the trusted list
|
||||||
|
nix.settings.trusted-users = [ "ryan" ];
|
||||||
|
|
||||||
# ... (other configurations omitted)
|
# ... (other configurations omitted)
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,15 @@ cat flake.nix
|
|||||||
# outputs 即 flake 的所有输出,其中的 nixosConfigurations 即 NixOS 系统配置
|
# outputs 即 flake 的所有输出,其中的 nixosConfigurations 即 NixOS 系统配置
|
||||||
# flake 有很多用途,也可以有很多不同的 outputs,nixosConfigurations 只是其中一种
|
# flake 有很多用途,也可以有很多不同的 outputs,nixosConfigurations 只是其中一种
|
||||||
#
|
#
|
||||||
# outputs 是一个函数,它的参数都在 inputs 中定义,可以通过 inputs 中定义的名称来引用。
|
# outputs 是一个函数,它的参数都在 inputs 中定义,可以通过 inputs 中定义的
|
||||||
|
# 名称来引用。
|
||||||
# 比如这里的输入参数 `nixpkgs`,就是上面 inputs 中的 `nixpkgs`
|
# 比如这里的输入参数 `nixpkgs`,就是上面 inputs 中的 `nixpkgs`
|
||||||
# 不过 self 是个例外,这个特殊参数指向 outputs 自身(自引用),以及 flake 根目录
|
# 不过 self 是个例外,这个特殊参数指向 outputs 自身(自引用),以及 flake 根目录
|
||||||
# 这里的 @ 语法将函数的参数 attribute set 取了个别名,方便在内部使用
|
# 这里的 @ 语法将函数的参数 attribute set 取了个别名,方便在内部使用
|
||||||
outputs = { self, nixpkgs, ... }@inputs: {
|
outputs = { self, nixpkgs, ... }@inputs: {
|
||||||
# 名为 nixosConfigurations 的 outputs 会在执行 `sudo nixos-rebuild switch`
|
# 名为 nixosConfigurations 的 outputs 会在执行
|
||||||
# 时被使用,默认情况下上述命令会使用与主机 hostname 同名的 nixosConfigurations
|
# `sudo nixos-rebuild switch` 时被使用
|
||||||
|
# 默认情况下上述命令会使用与主机 hostname 同名的 nixosConfigurations
|
||||||
# 但是也可以通过 `--flake /path/to/flake/direcotry#nixos-test` 来指定
|
# 但是也可以通过 `--flake /path/to/flake/direcotry#nixos-test` 来指定
|
||||||
# 在 flakes 配置文件夹中执行如下命令即可部署此配置:
|
# 在 flakes 配置文件夹中执行如下命令即可部署此配置:
|
||||||
# sudo nixos-rebuild switch --flake .#nixos-test
|
# sudo nixos-rebuild switch --flake .#nixos-test
|
||||||
@ -131,8 +133,9 @@ cat flake.nix
|
|||||||
# 常用于从 nixpkgs 中导入一些额外的模块
|
# 常用于从 nixpkgs 中导入一些额外的模块
|
||||||
# 这个参数通常都用不到,我只在制作 iso 镜像时用到过
|
# 这个参数通常都用不到,我只在制作 iso 镜像时用到过
|
||||||
#
|
#
|
||||||
# 上述默认参数都由 Nixpkgs 自动生成。而如果你需要将其他非默认参数传递到子模块,
|
# 上述默认参数都由 Nixpkgs 自动生成。而如果你需要将其他非默认参数传递到
|
||||||
# 就得使用 specialArgs 手动设定这些参数,你可以取消注释如下这行来启用该参数:
|
# 子模块,就得使用 specialArgs 手动设定这些参数,
|
||||||
|
# 你可以取消注释如下这行来启用该参数:
|
||||||
#
|
#
|
||||||
# specialArgs = {...}; # 将 inputs 中的参数传入所有子模块
|
# specialArgs = {...}; # 将 inputs 中的参数传入所有子模块
|
||||||
modules = [
|
modules = [
|
||||||
@ -278,7 +281,8 @@ warning: ignoring untrusted substituter 'https://mirrors.ustc.edu.cn/nix-channel
|
|||||||
{
|
{
|
||||||
# 省略若干配置...
|
# 省略若干配置...
|
||||||
|
|
||||||
nix.settings.trusted-users = [ "ryan" ]; # 将自己的用户名添加到可信列表中
|
# 将自己的用户名添加到可信列表中
|
||||||
|
nix.settings.trusted-users = [ "ryan" ];
|
||||||
|
|
||||||
# 省略若干配置...
|
# 省略若干配置...
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user