mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2024-11-24 17:13:12 +01:00
feat: update system, simplify nixos-related commands
This commit is contained in:
parent
08d834d05d
commit
b1a2957837
@ -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
|
||||
|
||||
############################################################################
|
||||
#
|
||||
|
@ -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`.
|
||||
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`.
|
||||
|
@ -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
|
||||
|
||||
############################################################################
|
||||
#
|
||||
|
@ -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 .
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user