diff options
| author | Malo Bourgon <mbourgon@gmail.com> | 2024-03-25 16:34:10 -0700 |
|---|---|---|
| committer | Malo Bourgon <mbourgon@gmail.com> | 2024-03-27 12:50:04 -0700 |
| commit | 398510f601cb1a1978a393814514f9ca9fbcfe72 (patch) | |
| tree | 5fbf5ed358041c70c9f50419b2e35504b9eff856 /modules/system | |
| parent | bcc8afd06e237df060c85bad6af7128e05fd61a3 (diff) | |
Add `nix.optimise` module
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/checks.nix | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/system/checks.nix b/modules/system/checks.nix index 27188e3..5989dc4 100644 --- a/modules/system/checks.nix +++ b/modules/system/checks.nix @@ -191,6 +191,17 @@ let exit 2 fi ''; + + nixStoreOptimiser = '' + if test -O /nix/store; then + echo "[1;31merror: A single-user install can't run optimiser as root, aborting activation[0m" >&2 + echo "Configure the optimiser to run as the current user:" >&2 + echo >&2 + echo " nix.optimiser.user = \"$USER\";" >&2 + echo >&2 + exit 2 + fi + ''; in { @@ -230,6 +241,7 @@ in (mkIf (!config.nix.useDaemon) singleUser) nixStore (mkIf (config.nix.gc.automatic && config.nix.gc.user == null) nixGarbageCollector) + (mkIf (config.nix.optimise.automatic && config.nix.optimise.user == null) nixStoreOptimiser) (mkIf cfg.verifyNixChannels nixChannels) nixInstaller (mkIf cfg.verifyNixPath nixPath) |
