From b8939c4fe41adbcb619b8ee477a309c8baca0dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=AErekc=C3=A4H=20nitraM=E2=80=AE?= Date: Mon, 24 Mar 2025 21:44:21 +0100 Subject: [PATCH] linux-builder: remove /nix/store external directory when disabled When /nix/store internal directories get renamed, they just don't get into the next version of your system closure and are thus no problem to rename. But state in the system is a problem, as there is no process to remov eit. Thus we need to do it ourselves. --- modules/nix/linux-builder.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index 7566303..93ab7ac 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -159,7 +159,13 @@ in ''; }; - config = mkIf cfg.enable { + config = mkMerge [ + (mkIf (!cfg.enable) { + system.activationScripts.preActivation.text = '' + rm -rf ${cfg.workingDirectory} + ''; + }) + (mkIf cfg.enable { assertions = [ { assertion = config.nix.enable; @@ -223,5 +229,6 @@ in }]; nix.settings.builders-use-substitutes = true; - }; + }) + ]; }