feat: debug

This commit is contained in:
Ryan Yin 2024-03-08 14:07:29 +08:00
parent 9326ad86ba
commit cff6c24370
8 changed files with 24 additions and 14 deletions

View File

@ -2,10 +2,14 @@
## Show detailed error messages
You can always try to add `--show-trace -L` to the `nixos-rebuild` command to get the detailed error message if you encounter any errors during the deployment. e.g.
You can always try to add `--show-trace --print-build-logs --verbose` to the `nixos-rebuild` command to get the detailed error message if you encounter any errors during the deployment. e.g.
```bash
sudo nixos-rebuild switch --flake .#myhost --show-trace -L
cd /etc/nixos
sudo nixos-rebuild switch --flake .#myhost --show-trace --print-build-logs --verbose
# A more concise version
sudo nixos-rebuild switch --flake .#myhost --show-trace -L -v
```
## Debugging with `nix repl`

View File

@ -62,7 +62,7 @@ In this configuration, we declare our intention to enable the openssh service, a
To deploy the modified configuration, run `sudo nixos-rebuild switch`. This command will apply the changes, generate a new system environment, and set it as the default. You can now log in to the system using SSH with the configured SSH keys.
> You can always try to add `--show-trace -L` to the `nixos-rebuild` command to get the detailed error message if you encounter any errors during the deployment.
> You can always try to add `--show-trace --print-build-logs --verbose` to the `nixos-rebuild` command to get the detailed error message if you encounter any errors during the deployment.
Remember that any reproducible changes to the system can be made by modifying the `/etc/nixos/configuration.nix` file and deploying the changes with `sudo nixos-rebuild switch`.

View File

@ -403,8 +403,6 @@ Make the necessary changes and deploy with `sudo nixos-rebuild switch`. The depl
After deployment, you can directly test and verify the installation using the `hx` command in the terminal.
> If you encounter any errors during deployment, you can try adding the `--show-trace -L` parameters to the `nixos-rebuild` command to get detailed error information.
Additionally, if you just want to try out the latest version of Helix and decide whether to install it on your system later, there is a simpler way to do it in one command (but as mentioned earlier, compiling from source will take a long time):
```bash

View File

@ -2,11 +2,14 @@
## Show detailed error messages
You can always try to add `--show-trace -L` to the `nixos-rebuild` command to get the detailed error message if you encounter any errors during the deployment. e.g.
You can always try to add `--show-trace --print-build-logs --verbose` to the `nixos-rebuild` command to get the detailed error message if you encounter any errors during the deployment. e.g.
```bash
cd /etc/nixos
sudo nixos-rebuild switch --flake .#myhost --show-trace -L
sudo nixos-rebuild switch --flake .#myhost --show-trace --print-build-logs --verbose
# A more concise version
sudo nixos-rebuild switch --flake .#myhost --show-trace -L -v
```
## Managing the Configuration with Git

View File

@ -2,10 +2,14 @@
## 查看详细错误信息
如果你在部署配置时遇到了任何错误,都可以尝试在 `nixos-rebuild` 命令后面添加 `--show-trace -L` 参数来获取详细的错误信息。举例如下:
如果你在部署配置时遇到了任何错误,都可以尝试在 `nixos-rebuild` 命令后面添加 `--show-trace --print-build-logs --verbose` 参数来获取详细的错误信息。举例如下:
```bash
sudo nixos-rebuild switch --flake .#myhost --show-trace -L
cd /etc/nixos
sudo nixos-rebuild switch --flake .#myhost --show-trace --print-build-logs --verbose
# 更简洁的版本
sudo nixos-rebuild switch --flake .#myhost --show-trace -L -v
```
## 通过 `nix repl` 查看源码、调试配置

View File

@ -67,7 +67,7 @@ NixOS 的系统配置路径为 `/etc/nixos/configuration.nix`,它包含系统
现在运行 `sudo nixos-rebuild switch` 部署修改后的配置,之后就可以通过 ssh 密钥远程登录到我的这台主机了。
> 如果你在部署配置时遇到了任何错误,都可以尝试在 `nixos-rebuild` 命令后面添加 `--show-trace -L` 参数来获取详细的错误信息。举例如下:
> 如果你在部署配置时遇到了任何错误,都可以尝试在 `nixos-rebuild` 命令后面添加 `--show-trace --print-build-logs --verbose` 参数来获取详细的错误信息。举例如下:
这就是 NixOS 默认的声明式系统配置,要对系统做任何可复现的变更,都只需要修改 `/etc/nixos/configuration.nix` 文件,然后运行 `sudo nixos-rebuild switch` 部署变更即可。

View File

@ -405,8 +405,6 @@ NixOS 社区比较推荐优先使用 `_module.args` 这个 options仅在无
部署完毕后,可直接在终端使用 `hx` 命令测试验证。
> 如果你在部署配置时遇到了任何错误,都可以尝试在 `nixos-rebuild` 命令后面添加 `--show-trace -L` 参数来获取详细的错误信息。
另外,如果你只是想尝试一下 Helix 的最新版本,再决定要不要真正地将它安装到系统里,有更简单的办法,一行命令就行(但如前所述,源码编译会很费时间):
```bash

View File

@ -2,11 +2,14 @@
## 查看详细错误信息
如果你在部署配置时遇到了任何错误,都可以尝试在 `nixos-rebuild` 命令后面添加 `--show-trace -L` 参数来获取详细的错误信息。举例如下:
如果你在部署配置时遇到了任何错误,都可以尝试在 `nixos-rebuild` 命令后面添加 `--show-trace --print-build-logs --verbose` 参数来获取详细的错误信息。举例如下:
```bash
cd /etc/nixos
sudo nixos-rebuild switch --flake .#myhost --show-trace -L
sudo nixos-rebuild switch --flake .#myhost --show-trace --print-build-logs --verbose
# 更简洁的版本
sudo nixos-rebuild switch --flake .#myhost --show-trace -L -v
```
## 使用 Git 管理 NixOS 配置 {#git-manage-nixos-config}