mirror of
https://github.com/ryan4yin/nixos-and-flakes-book
synced 2024-11-26 22:10:26 +00:00
feat: add content - reduce disk usage
This commit is contained in:
parent
ea8d7edc52
commit
86ab7528ff
2 changed files with 57 additions and 0 deletions
|
@ -65,3 +65,32 @@ Another command returns all packages installed in the system:
|
||||||
```shell
|
```shell
|
||||||
nix-env -qa
|
nix-env -qa
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Reduce Disk Usage
|
||||||
|
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
# ......
|
||||||
|
|
||||||
|
# do not need to keep too much generations
|
||||||
|
boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10;
|
||||||
|
# boot.loader.grub.configurationLimit = 10;
|
||||||
|
|
||||||
|
# do garbage collection weekly to keep disk usage low
|
||||||
|
nix.gc = {
|
||||||
|
automatic = lib.mkDefault true;
|
||||||
|
dates = lib.mkDefault "weekly";
|
||||||
|
options = lib.mkDefault "--delete-older-than 1w";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Optimise storage
|
||||||
|
# you can alse optimise the store manually via:
|
||||||
|
# nix-store --optimise
|
||||||
|
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
|
||||||
|
nix.settings.auto-optimise-store = true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -62,3 +62,31 @@ sudo nix store gc --debug
|
||||||
```shell
|
```shell
|
||||||
nix-env -qa
|
nix-env -qa
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 节约存储空间
|
||||||
|
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
# ......
|
||||||
|
|
||||||
|
# do not need to keep too much generations
|
||||||
|
boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10;
|
||||||
|
# boot.loader.grub.configurationLimit = 10;
|
||||||
|
|
||||||
|
# do garbage collection weekly to keep disk usage low
|
||||||
|
nix.gc = {
|
||||||
|
automatic = lib.mkDefault true;
|
||||||
|
dates = lib.mkDefault "weekly";
|
||||||
|
options = lib.mkDefault "--delete-older-than 1w";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Optimise storage
|
||||||
|
# you can alse optimise the store manually via:
|
||||||
|
# nix-store --optimise
|
||||||
|
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
|
||||||
|
nix.settings.auto-optimise-store = true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue