diff --git a/docs/best-practices/simplify-nixos-related-commands.md b/docs/best-practices/simplify-nixos-related-commands.md index 3b64d7b..1b7a990 100644 --- a/docs/best-practices/simplify-nixos-related-commands.md +++ b/docs/best-practices/simplify-nixos-related-commands.md @@ -23,18 +23,28 @@ deploy: debug: nixos-rebuild switch --flake . --use-remote-sudo --show-trace --verbose -update: +up: nix flake update +# Update specific input +# usage: make upp i=home-manager +upp: + nix flake lock --update-input $(i) + history: nix profile history --profile /nix/var/nix/profiles/system -gc: +repl: + nix repl -f flake:nixpkgs + +clean: # remove all generations older than 7 days sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d +gc: # garbage collect all unused nix store entries sudo nix store gc --debug + sudo nix-collect-garbage --delete-old ############################################################################ # diff --git a/docs/nixos-with-flakes/update-the-system.md b/docs/nixos-with-flakes/update-the-system.md index 1510697..722fc16 100644 --- a/docs/nixos-with-flakes/update-the-system.md +++ b/docs/nixos-with-flakes/update-the-system.md @@ -6,8 +6,11 @@ With Flakes, updating the system is straightforward. Simply execute the followin # Update flake.lock nix flake update +# Or replace only the specific input, such as home-manager: +nix flake lock --update-input home-manager + # Apply the updates sudo nixos-rebuild switch --flake . ``` -Occasionally, you may encounter a "sha256 mismatch" error when running `nixos-rebuild switch`. This error can be resolved by updating `flake.lock` using `nix flake update`. \ No newline at end of file +Occasionally, you may encounter a "sha256 mismatch" error when running `nixos-rebuild switch`. This error can be resolved by updating `flake.lock` using `nix flake update`. diff --git a/docs/zh/best-practices/simplify-nixos-related-commands.md b/docs/zh/best-practices/simplify-nixos-related-commands.md index c06d624..f965005 100644 --- a/docs/zh/best-practices/simplify-nixos-related-commands.md +++ b/docs/zh/best-practices/simplify-nixos-related-commands.md @@ -24,18 +24,28 @@ deploy: debug: nixos-rebuild switch --flake . --use-remote-sudo --show-trace --verbose -update: +up: nix flake update +# Update specific input +# usage: make upp i=home-manager +upp: + nix flake lock --update-input $(i) + history: nix profile history --profile /nix/var/nix/profiles/system -gc: +repl: + nix repl -f flake:nixpkgs + +clean: # remove all generations older than 7 days sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d +gc: # garbage collect all unused nix store entries sudo nix store gc --debug + sudo nix-collect-garbage --delete-old ############################################################################ # diff --git a/docs/zh/nixos-with-flakes/update-the-system.md b/docs/zh/nixos-with-flakes/update-the-system.md index 2f17186..a5cedd7 100644 --- a/docs/zh/nixos-with-flakes/update-the-system.md +++ b/docs/zh/nixos-with-flakes/update-the-system.md @@ -3,8 +3,12 @@ 在使用了 Nix Flakes 后,要更新系统也很简单,先更新 flake.lock 文件,然后部署即可。在配置文件夹中执行如下命令: ```shell -# 更新 flake.lock +# 更新 flake.lock(更新所有依赖项) nix flake update + +# 或者也可以只更新特定的依赖项,比如只更新 home-manager: +nix flake lock --update-input home-manager + # 部署系统 sudo nixos-rebuild switch --flake . ```