Skip to content

Commit

Permalink
feat: update system, simplify nixos-related commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan4yin committed Jan 11, 2024
1 parent 08d834d commit b1a2957
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
14 changes: 12 additions & 2 deletions docs/best-practices/simplify-nixos-related-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

############################################################################
#
Expand Down
5 changes: 4 additions & 1 deletion docs/nixos-with-flakes/update-the-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
14 changes: 12 additions & 2 deletions docs/zh/best-practices/simplify-nixos-related-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

############################################################################
#
Expand Down
6 changes: 5 additions & 1 deletion docs/zh/nixos-with-flakes/update-the-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
```
Expand Down

0 comments on commit b1a2957

Please sign in to comment.