Nixos/activation doesn't build locally anymore

For a couple of weeks now, rebuilding my systems activation script consumes a significant amount of time, as it is not built locally anymore. Uploading all the closures to the remote builder on a 50 Mbit/s connection takes about 30 to 60 minutes depending on how much is already available on the other side.

I did some research in the PRs that touched the activation script generator.

The most relevant one I have found has been:

I therefore created an issue, but so far did not get any responses, therefore I wanted to raise awareness here.

Maybe someone knows a quick and easy fix to restore the old behavior? Even though I have prepared a potential fix locally, I currently can not submit it as I messed up my clone. And my computer wouldn’t have the capacity to build staging anyway…

Therefore I put my theory here for discussion until I can fix my setup for a PR. (hopefully within the next 24h).

diff --git a/nixos/modules/system/activation/activatable-system.nix b/nixos/modules/system/activation/activatable-system.nix
index 6513706b27..7d1028a79a 100644
--- a/nixos/modules/system/activation/activatable-system.nix
+++ b/nixos/modules/system/activation/activatable-system.nix
@@ -49,20 +49,22 @@
   config =
     let
       activationScript = lib.getExe (
-        pkgs.writeShellApplication {
+        (pkgs.writeShellApplication {
           name = "activate";
           text = config.system.activationScripts.script;
           checkPhase = "";
           bashOptions = [ ];
-        }
+        }).overrideAttrs
+          { preferLocalBuild = true; }
       );
       dryActivationScript = lib.getExe (
-        pkgs.writeShellApplication {
+        (pkgs.writeShellApplication {
           name = "dry-activate";
           text = config.system.dryActivationScript;
           checkPhase = "";
           bashOptions = [ ];
-        }
+        }).overrideAttrs
+          { preferLocalBuild = true; }
       );
     in
     {
3 Likes

I was able to fix my setup and created a pull request: