From 31015cfb432c813534eb7769ecd099bae7951823 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Thu, 6 Jul 2023 11:04:52 +0800 Subject: [PATCH] feat: minor updates --- docs/advanced-topics/index.md | 6 +++-- .../run-downloaded-binaries-on-nixos.md | 2 +- .../simplify-nixos-related-commands.md | 24 +++++++------------ docs/development/distributed-building.md | 4 +--- docs/development/intro.md | 8 +++---- docs/development/kernel-development.md | 1 + .../nixos-with-flakes-enabled.md | 4 +--- .../start-using-home-manager.md | 2 +- docs/other-usage-of-flakes/inputs.md | 4 +++- docs/other-usage-of-flakes/outputs.md | 2 -- docs/other-usage-of-flakes/the-new-cli.md | 3 +-- docs/zh/development/intro.md | 2 +- docs/zh/development/kernel-development.md | 1 + .../start-using-home-manager.md | 2 +- 14 files changed, 28 insertions(+), 37 deletions(-) diff --git a/docs/advanced-topics/index.md b/docs/advanced-topics/index.md index fa35675..d69fb8c 100644 --- a/docs/advanced-topics/index.md +++ b/docs/advanced-topics/index.md @@ -19,8 +19,8 @@ Once you are comfortable with Flakes, you can explore more advanced techniques a There are many other valuable community projects worth exploring. Here are a few examples: -- [nixpak](https://github.com/nixpak/nixpak) -- [nix-output-monitor](https://github.com/maralorn/nix-output-monitor) +- [nixpak](https://github.com/nixpak/nixpak): A tool to sandbox all sorts of Nix-packaged applications, including graphical ones. +- [nix-output-monitor](https://github.com/maralorn/nix-output-monitor): Beautifully displays the build progress of Nix packages, with additional information such as build time and build log. - [agenix](https://github.com/ryantm/agenix): A tool for secrets management. - [colmena](https://github.com/zhaofengli/colmena): Tools for NixOS deployment. - [nixos-generators](https://github.com/nix-community/nixos-generators): A tool to generate ISO/qcow2/... from NixOS configurations. @@ -28,3 +28,5 @@ There are many other valuable community projects worth exploring. Here are a few - [impermanence](https://github.com/nix-community/impermanence): Helps make NixOS stateless and improves system reproducibility. These projects offer additional functionality and tools that can enhance your NixOS experience. + +For more information, see the [awesome-nix](https://github.com/nix-community/). diff --git a/docs/best-practices/run-downloaded-binaries-on-nixos.md b/docs/best-practices/run-downloaded-binaries-on-nixos.md index 91d2268..55011a5 100644 --- a/docs/best-practices/run-downloaded-binaries-on-nixos.md +++ b/docs/best-practices/run-downloaded-binaries-on-nixos.md @@ -2,7 +2,7 @@ Since NixOS does not strictly adhere to the Filesystem Hierarchy Standard (FHS), binaries downloaded from the internet may not work directly on NixOS. However, there are various methods available to make them function properly. -For a comprehensive guide that presents ten different approaches to run downloaded binaries on NixOS, I recommend reading the article [Different methods to run a non-nixos executable on Nixos](https://unix.stackexchange.com/questions/522822/different-methods-to-run-a-non-nixos-executable-on-nixos). +For a comprehensive guide that presents ten different approaches to run downloaded binaries on NixOS, I recommend reading the article [Different methods to run a non-nixos executable on Nixos](https://unix.stackexchange.com/questions/522822/different-methods-to-run-a-non-nixos-executable-on-nixos) and take a look at [nix-alien](https://github.com/thiagokokada/nix-alien). Among these methods, I personally prefer creating an FHS environment to run the binary, as it proves to be both convenient and easy to use. To set up such an environment, you can add the following code to one of your Nix modules: diff --git a/docs/best-practices/simplify-nixos-related-commands.md b/docs/best-practices/simplify-nixos-related-commands.md index e42abdf..460af4e 100644 --- a/docs/best-practices/simplify-nixos-related-commands.md +++ b/docs/best-practices/simplify-nixos-related-commands.md @@ -1,16 +1,14 @@ # Simplifying NixOS-Related Commands -To simplify NixOS-related commands, I utilize a Makefile, which proves to be very convenient. Alternatively, you can also use similar tools like [just](https://github.com/casey/just) and [cargo-make](https://github.com/sagiegurari/cargo-make) for this purpose. Here, I will provide my approach as a reference. +To simplify NixOS-related commands, I utilize a Makefile, which proves to be very convenient. + +Alternatively, you can also use similar tools like [just](https://github.com/casey/just) and [cargo-make](https://github.com/sagiegurari/cargo-make) for this purpose. Here, I will provide my approach as a reference. Below is an example of how my Makefile looks: +>**NOTE**: The target names in the Makefile should not conflict with any file or directory names in the current directory. Otherwise, the targets will not execute. + ```makefile -# -# NOTE: The target names in the Makefile should not conflict with any file or directory names in the current directory. -# Otherwise, the targets will not execute. -# - - ############################################################################ # # Nix commands related to the local machine @@ -57,17 +55,11 @@ ruby: add-idols-ssh-key ruby-debug: add-idols-ssh-key nixos-rebuild --flake .#ruby --target-host ruby --build-host ruby switch --use-remote-sudo --show-trace --verbose -kana: add-idols-ssh-key - nixos-rebuild --flake .#kana --target-host kana --build-host kana switch --use-remote-sudo +idols: aqua ruby -kana-debug: add-idols-ssh-key - nixos-rebuild --flake .#kana --target-host kana --build-host kana switch --use-remote-sudo --show-trace --verbose - -idols: aqua ruby kana - -idols-debug: aqua-debug ruby-debug kana-debug +idols-debug: aqua-debug ruby-debug ``` -Save the above Makefile to the root directory of your Nix flake. Then, you can use `make deploy` to deploy the configuration to your local machine and `make aqua` to deploy the configuration to all your remote servers. +By Save the above Makefile to the root directory of your Nix flake. Then, I can use `make deploy` to deploy the configuration to my local machine, and `make idols` to deploy the configuration to all my remote servers. This approach simplifies the execution of NixOS commands by abstracting them behind target names in the Makefile, providing a more user-friendly and convenient experience. \ No newline at end of file diff --git a/docs/development/distributed-building.md b/docs/development/distributed-building.md index 9254503..d794a18 100644 --- a/docs/development/distributed-building.md +++ b/docs/development/distributed-building.md @@ -78,9 +78,7 @@ Currently, there is no official documentation for distributed building. However, ]; # Optional: Useful when the builder has a faster internet connection than yours. nix.extraOptions = '' - builders-use-sub - -stitutes = true + builders-use-substitutes = true ''; # Define the host aliases for remote builders. diff --git a/docs/development/intro.md b/docs/development/intro.md index f7409fd..8cd8e5b 100644 --- a/docs/development/intro.md +++ b/docs/development/intro.md @@ -261,7 +261,7 @@ hello: command not found Hello, world! ``` -`nix run` is used to create an environment containing the specified installable and run the installable in it: +`nix run` is used to create an environment containing the specified installable and run the installable in it(without install it to the system): ```shell # hello not exists @@ -277,9 +277,9 @@ Because `nix run` will directly run the Nix package as an installable, the Nix p According to the description of `nix run --help`, `nix run` will execute `/bin/`, where `` is the root directory of a Derivation, and `` is selected in the following order: -- The meta.mainProgram attribute of the derivation. -- The pname attribute of the derivation. -- The name part of the value of the name attribute of the derivation. +- The `meta.mainProgram` attribute of the derivation. +- The `pname` attribute of the derivation. +- The `name` part of the value of the name attribute of the derivation. For instance, if name is set to `hello-1.10`, nix run will run $out/bin/hello. diff --git a/docs/development/kernel-development.md b/docs/development/kernel-development.md index b559916..3581c3d 100644 --- a/docs/development/kernel-development.md +++ b/docs/development/kernel-development.md @@ -112,4 +112,5 @@ To solve this problem, I add a `fhs` environment to install the `ncurses` packag ## References +- [Linux kernel - NixOS Wiki](https://nixos.wiki/wiki/Linux_kernel) - https://github.com/jordanisaacs/kernel-module-flake diff --git a/docs/nixos-with-flakes/nixos-with-flakes-enabled.md b/docs/nixos-with-flakes/nixos-with-flakes-enabled.md index 595f068..6ff6109 100644 --- a/docs/nixos-with-flakes/nixos-with-flakes-enabled.md +++ b/docs/nixos-with-flakes/nixos-with-flakes-enabled.md @@ -227,9 +227,7 @@ To customize the cache source, we must add the related configuration in `flake.n "https://cache.nixos.org/" ]; - extra-sub - -stituters = [ + extra-substituters = [ # Nix community's cache server "https://nix-community.cachix.org" ]; diff --git a/docs/nixos-with-flakes/start-using-home-manager.md b/docs/nixos-with-flakes/start-using-home-manager.md index ab91dd9..ef5b663 100644 --- a/docs/nixos-with-flakes/start-using-home-manager.md +++ b/docs/nixos-with-flakes/start-using-home-manager.md @@ -84,7 +84,7 @@ According to the official [Home Manager Manual](https://nix-community.github.io/ # nix related # - # it provides the command `nom` works just like `nix + # it provides the command `nom` works just like `nix` # with more details log output nix-output-monitor diff --git a/docs/other-usage-of-flakes/inputs.md b/docs/other-usage-of-flakes/inputs.md index 2d4903e..b23d4a0 100644 --- a/docs/other-usage-of-flakes/inputs.md +++ b/docs/other-usage-of-flakes/inputs.md @@ -36,6 +36,8 @@ The `inputs` in `flake.nix` is an attribute set, used to specify the dependencie # To use a subdirectory of a repo, pass `dir=xxx` nixpkgs.url = "github:foo/bar?dir=shu"; - } + }; + + outputs = { self, ... }@inputs: { ... }; } ``` diff --git a/docs/other-usage-of-flakes/outputs.md b/docs/other-usage-of-flakes/outputs.md index 5b39aa1..7f1a4f3 100644 --- a/docs/other-usage-of-flakes/outputs.md +++ b/docs/other-usage-of-flakes/outputs.md @@ -62,6 +62,4 @@ Here's an example excerpt from the NixOS Wiki that demonstrates the structure of templates.default = { path = ""; description = ""; }; }; } - - ``` diff --git a/docs/other-usage-of-flakes/the-new-cli.md b/docs/other-usage-of-flakes/the-new-cli.md index 1e6ac77..459d1e7 100644 --- a/docs/other-usage-of-flakes/the-new-cli.md +++ b/docs/other-usage-of-flakes/the-new-cli.md @@ -32,7 +32,6 @@ nix build "nixpkgs#bat" # build a local flake is the same as nix develop, skip it ``` -[Zero to Nix - Determinate Systems][Zero to Nix - Determinate Systems] is a brand new guide to get started with Nix & Flake, recommended to read for beginners. +We will introduce more details about `nix develop`, `nix shell` and `nix run` in the next chapter. [New Nix Commands]: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html -[Zero to Nix - Determinate Systems]: https://github.com/DeterminateSystems/zero-to-nix diff --git a/docs/zh/development/intro.md b/docs/zh/development/intro.md index 95b5104..76ea1ff 100644 --- a/docs/zh/development/intro.md +++ b/docs/zh/development/intro.md @@ -265,7 +265,7 @@ hello: command not found Hello, world! ``` -`nix run` 则是创建一个含有指定 Nix 包的环境,并在该环境中直接运行该 Nix 包: +`nix run` 则是创建一个含有指定 Nix 包的环境,并在该环境中直接运行该 Nix 包(临时运行该程序,不将它安装到系统环境中): ```shell # hello 不存在 diff --git a/docs/zh/development/kernel-development.md b/docs/zh/development/kernel-development.md index f056b0f..ce9190e 100644 --- a/docs/zh/development/kernel-development.md +++ b/docs/zh/development/kernel-development.md @@ -113,4 +113,5 @@ ## References +- [Linux kernel - NixOS Wiki](https://nixos.wiki/wiki/Linux_kernel) - https://github.com/jordanisaacs/kernel-module-flake diff --git a/docs/zh/nixos-with-flakes/start-using-home-manager.md b/docs/zh/nixos-with-flakes/start-using-home-manager.md index 1974de2..dcf5a2e 100644 --- a/docs/zh/nixos-with-flakes/start-using-home-manager.md +++ b/docs/zh/nixos-with-flakes/start-using-home-manager.md @@ -84,7 +84,7 @@ # nix related # - # it provides the command `nom` works just like `nix + # it provides the command `nom` works just like `nix` # with more details log output nix-output-monitor