diff --git a/docs/best-practices/debug-with-nix-repl.md b/docs/best-practices/debugging.md similarity index 92% rename from docs/best-practices/debug-with-nix-repl.md rename to docs/best-practices/debugging.md index 7346f4d..96cc2db 100644 --- a/docs/best-practices/debug-with-nix-repl.md +++ b/docs/best-practices/debugging.md @@ -1,4 +1,6 @@ -# Debugging with `nix repl` +# Debugging Derivations and Nix Expressions + +## Debugging with `nix repl` We have frequently used nix repl `` throughout this guide to examine the source code. It is a powerful tool that helps us understand how things work in Nix. @@ -141,3 +143,19 @@ outputs.nixosConfigurations.ai.config.home-manager.users.ryan.home.file..config/ ``` As you can see, after loading your Nix flake into the REPL, you can check every attribute of the flake. This capability is very convenient for debugging purposes. + + +## Debugging functions provided by nixpkgs + +TODO + +## Debugging by using `NIX_DEBUG` in derivation + +TODO + +## References + +- [How to make nix build display all commands executed by make?](https://www.reddit.com/r/NixOS/comments/14stdgy/how_to_make_nix_build_display_all_commands/) + - use `NIX_DEBUG=7` in derivation +- [Collection of functions useful for debugging broken nix expressions.](https://github.com/NixOS/nixpkgs/blob/master/lib/debug.nix) + diff --git a/docs/zh/best-practices/debug-with-nix-repl.md b/docs/zh/best-practices/debugging.md similarity index 91% rename from docs/zh/best-practices/debug-with-nix-repl.md rename to docs/zh/best-practices/debugging.md index d6a89d3..4ddbcc9 100644 --- a/docs/zh/best-practices/debug-with-nix-repl.md +++ b/docs/zh/best-practices/debugging.md @@ -1,4 +1,6 @@ -# 通过 `nix repl` 查看源码、调试配置 +# 调试 Derivation 跟 Nix 表达式 + +## 通过 `nix repl` 查看源码、调试配置 前面我们已经使用 `nix repl ''` 看过很多次源码了,这是一个非常强大的工具,可以帮助我们理解 Nix 的工作原理。 @@ -137,3 +139,20 @@ outputs.nixosConfigurations.ai.config.home-manager.users.ryan.home.file..config/ ``` 能看到,通过 `nix repl` 加载好我的 flake 配置后,就能很方便地检查所有的配置项了,这对于调试非常有用。 + + +## 使用 nixpkgs 中提供的调试函数 + +TODO + +## 使用 derivation 的 `NIX_DEBUG` 参数调试 + +TODO + +## 参考文档 + +- [How to make nix build display all commands executed by make?](https://www.reddit.com/r/NixOS/comments/14stdgy/how_to_make_nix_build_display_all_commands/) + - use `NIX_DEBUG=7` in derivation +- [Collection of functions useful for debugging broken nix expressions.](https://github.com/NixOS/nixpkgs/blob/master/lib/debug.nix) + +