From 398510f601cb1a1978a393814514f9ca9fbcfe72 Mon Sep 17 00:00:00 2001 From: Malo Bourgon Date: Mon, 25 Mar 2024 16:34:10 -0700 Subject: Add `nix.optimise` module --- modules/system/checks.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'modules/system') 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 "error: A single-user install can't run optimiser as root, aborting activation" >&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) -- cgit v1.2.3