NobbZ
January 16, 2026, 12:51pm
1
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:
staging-nixos ← r-vdp:rvdp/activationscript
opened 04:32PM - 26 Dec 25 UTC
## Things done
Two improvements:
* use `writeShellApplication` (which uses… `passAsFile` instead of passing the activation script as an env var into the derivation. We disable shellcheck and the bash options that this builder usually adds to avoid issues with out-of-tree activation scripts.
* use `sed` instead of `substituteInPlace`, since the substitute functions load the file content into a shell variable
This avoids issues when the activation is too long to fit in a shell variable.
Before this commit, a very large activation script, would cause build failures because of different limits on the file content size, e.g.
```
➜ nix build -f . nixosTests.restartByActivationScript.nodes.machine.system.build.toplevel -vL
this derivation will be built:
/nix/store/xw6anpfjyamnycjg58cmj01sz3ididyl-nixos-system-machine-test.drv
building '/nix/store/xw6anpfjyamnycjg58cmj01sz3ididyl-nixos-system-machine-test.drv'...
nixos-system-machine-test> error: executing '/nix/store/rlq03x4cwf8zn73hxaxnx0zn5q9kifls-bash-5.3p3/bin/bash': Argument list too long
error: builder for '/nix/store/xw6anpfjyamnycjg58cmj01sz3ididyl-nixos-system-machine-test.drv' failed with exit code 1;
last 1 log lines:
> error: executing '/nix/store/rlq03x4cwf8zn73hxaxnx0zn5q9kifls-bash-5.3p3/bin/bash': Argument list too long
For full logs, run:
nix log /nix/store/xw6anpfjyamnycjg58cmj01sz3ididyl-nixos-system-machine-test.drv
```
- Built on platform:
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- Tested, as applicable:
- [x] [NixOS tests] in [nixos/tests].
- [ ] [Package tests] at `passthru.tests`.
- [ ] Tests in [lib/tests] or [pkgs/test] for functions and "core" functionality.
- [ ] Ran `nixpkgs-review` on this PR. See [nixpkgs-review usage].
- [ ] Tested basic functionality of all binary files, usually in `./result/bin/`.
- Nixpkgs Release Notes
- [ ] Package update: when the change is major or breaking.
- NixOS Release Notes
- [ ] Module addition: when adding a new NixOS module.
- [ ] Module update: when the change is significant.
- [ ] Fits [CONTRIBUTING.md], [pkgs/README.md], [maintainers/README.md] and other READMEs.
[NixOS tests]: https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests
[Package tests]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests
[nixpkgs-review usage]: https://github.com/Mic92/nixpkgs-review#usage
[CONTRIBUTING.md]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
[lib/tests]: https://github.com/NixOS/nixpkgs/blob/master/lib/tests
[maintainers/README.md]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md
[nixos/tests]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests
[pkgs/README.md]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md
[pkgs/test]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/test
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
I therefore created an issue, but so far did not get any responses, therefore I wanted to raise awareness here.
opened 04:57PM - 13 Jan 26 UTC
0.kind: bug
### Nixpkgs version
- Unstable (26.05)
### Describe the bug
Since recently th… e activation is built on a connected builder rather than locally, which delays my builds by up to 45 minutes to push a huge part of the closure to a remote builder via a 50 Mbit/s connection…
As far as I can tell #474379 might be related as `writeShellApplication` defaults to `preferLocalBuild = false`.
Is this change in behaviour intentional, if so, what is the reasoning behind it?
### Steps to reproduce
Build system configuration with remote builders connected via a slow-ish connection while also having a huge system closure
### Expected behaviour
The shellscript is built locally, its just a concatenation of strings at the end!
### Screenshots
_No response_
### Relevant log output
```console
```
### Additional context
_No response_
### System metadata
- system: `"x86_64-linux"`
- host os: `Linux 6.18.2, NixOS, 26.05 (Yarara), 26.05.20260111.ffbc9f8`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.34.0pre20260113_1bddbff`
- channels(aroemer): `"nixpkgs-21.11"`
- channels(nmelzer): `""`
- channels(root): `""`
- nixpkgs: `/nix/store/ln4j1iqnnzs2ynx2cr88bdh65fmds2aq-source`
### Notify maintainers
No explicit maintainer found, therefore pining the author of the related PR:
- @r-vdp
---
**Note for maintainers:** Please tag this issue in your pull request description. (i.e. `Resolves #ISSUE`.)
### I assert that this issue is relevant for Nixpkgs
- [x] I assert that this is a bug and not a support request.
- [x] I assert that this is not a [duplicate of an existing issue](https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+label%3A%220.kind%3A+bug%22+-label%3A%226.topic%3A+darwin%22+-label%3A%226.topic%3A+nixos%22).
- [x] I assert that I have read the [NixOS Code of Conduct](https://github.com/NixOS/.github/blob/master/CODE_OF_CONDUCT.md) and agree to abide by it.
### Is this issue important to you?
Add a :+1: [reaction] to [issues you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[issues you find important]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
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
NobbZ
January 17, 2026, 11:22am
2
I was able to fix my setup and created a pull request:
staging-nixos ← NobbZ:prefer-local-build-for-activation-script
opened 11:22AM - 17 Jan 26 UTC
This should re-enable local builds for the activation script.
FIX #479747
…
## Things done
- Built on platform:
- [ ] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- Tested, as applicable:
- [ ] [NixOS tests] in [nixos/tests].
- [ ] [Package tests] at `passthru.tests`.
- [ ] Tests in [lib/tests] or [pkgs/test] for functions and "core" functionality.
- [ ] Ran `nixpkgs-review` on this PR. See [nixpkgs-review usage].
- [ ] Tested basic functionality of all binary files, usually in `./result/bin/`.
- Nixpkgs Release Notes
- [ ] Package update: when the change is major or breaking.
- NixOS Release Notes
- [ ] Module addition: when adding a new NixOS module.
- [ ] Module update: when the change is significant.
- [ ] Fits [CONTRIBUTING.md], [pkgs/README.md], [maintainers/README.md] and other READMEs.
[NixOS tests]: https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests
[Package tests]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests
[nixpkgs-review usage]: https://github.com/Mic92/nixpkgs-review#usage
[CONTRIBUTING.md]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
[lib/tests]: https://github.com/NixOS/nixpkgs/blob/master/lib/tests
[maintainers/README.md]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md
[nixos/tests]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests
[pkgs/README.md]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md
[pkgs/test]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/test
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc