You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also thought about write-tree. But I think doing write-file first is a quick win and write-tree can come later, since I think there is more discussion required.
Another feature that write-file would be good to have, is adding an executable flag. So we can easier declare scripts (for example in flake outputs) without nixpkgs.
Writing executable files could also be done by another builtin. something like builtin:write-script
There's the concern that this feature will be very hard to polyfill, since there's no good way of detecting if the store layer supports the right builtin derivation builder. It's unclear what the path to adoption could look like even if this gets implemented. The evaluator doesn't really know what sort of store layer implementation could try building the derivation.
Yesterday i wrote a flake check and i wanted it to be quick. So i avoided the standard environment and used the low-level derivation.
Since derivation requires an output (which i also don't fully understand why that is. Just require dependencies not to be empty) I had to use busybox as a builder only so i can write the output of my check program to the output.
I would have loved to just put one pkg, in this case single binary and the data the check runs on, into the derivation and write some output file without needing a shell^^
@ranomier I think we're trying to benefit from not having to run any user code for this type of derivation.
What you're describing seems to be a pretty normal derivation in terms of execution; just a slightly modified output behavior.
Alternative solution ideas for your use case:
No-output derivations, but that would make the "executed builder" unrepresentable as an output, which would put pressure on the system design to be more complex, having to work with both outputs and derivation executions in many places, like the CLI. Doesn't feel like the right direction to me.
A derivation flag ("advanced attribute") that captures stdout as a file output
Extra bonus points if we manage to keep this arch-agnostic from a builder perspective.
When deploying an aarch64 machine from an x86 one, you currently end up building the configuration files using the emulation compatibility layer, which tend to be reaaaaly slow.
It'd be great to be able to always build these text files using the build platform instead of the host one.
I'm not sure if this could backfire in some situations, though. From the top of my head, I don't see such a situation.
This would also be great for unit testing.
Even more so if we can sneak in build-time dependencies somehow so that we can instantly create a store with varied store path relations.
Another interesting aspect is support for disallowedReferences and the other related checks.
I'm not sure that's the best way to sneak in built-time deps, because we've talked about automatically dropping context for those disallow rules (to avoid pulling in unused deps when they're not also referenced by the productive parts of the derivation).
For polyfill, content-addressing helps a little bit, because it means the choice of a "real" derivation or built-in derivation doesn't affect output paths.
Activity
Mic92 commentedon Sep 17, 2025
cc @lassulus
lassulus commentedon Sep 17, 2025
I also thought about write-tree. But I think doing write-file first is a quick win and write-tree can come later, since I think there is more discussion required.
Another feature that write-file would be good to have, is adding an executable flag. So we can easier declare scripts (for example in flake outputs) without nixpkgs.
Writing executable files could also be done by another builtin. something like builtin:write-script
xokdvium commentedon Sep 17, 2025
There's the concern that this feature will be very hard to polyfill, since there's no good way of detecting if the store layer supports the right builtin derivation builder. It's unclear what the path to adoption could look like even if this gets implemented. The evaluator doesn't really know what sort of store layer implementation could try building the derivation.
nixos-discourse commentedon Sep 17, 2025
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2025-09-17-nix-team-meeting-minutes-248/69508/1
ranomier commentedon Sep 22, 2025
Potential use case:
Yesterday i wrote a flake check and i wanted it to be quick. So i avoided the standard environment and used the low-level derivation.
Since derivation requires an output (which i also don't fully understand why that is. Just require dependencies not to be empty) I had to use busybox as a builder only so i can write the output of my check program to the output.
I would have loved to just put one pkg, in this case single binary and the data the check runs on, into the derivation and write some output file without needing a shell^^
roberth commentedon Sep 24, 2025
@ranomier I think we're trying to benefit from not having to run any user code for this type of derivation.
What you're describing seems to be a pretty normal derivation in terms of execution; just a slightly modified output behavior.
Alternative solution ideas for your use case:
picnoir commentedon Sep 26, 2025
Extra bonus points if we manage to keep this arch-agnostic from a builder perspective.
When deploying an aarch64 machine from an x86 one, you currently end up building the configuration files using the emulation compatibility layer, which tend to be reaaaaly slow.
It'd be great to be able to always build these text files using the build platform instead of the host one.
I'm not sure if this could backfire in some situations, though. From the top of my head, I don't see such a situation.
Mic92 commentedon Oct 1, 2025
Remote building NixOS i.e. if architectures are not matching is also one of my motivations for this.
roberth commentedon Oct 14, 2025
This would also be great for unit testing.
Even more so if we can sneak in build-time dependencies somehow so that we can instantly create a store with varied store path relations.
Another interesting aspect is support for
disallowedReferencesand the other related checks.I'm not sure that's the best way to sneak in built-time deps, because we've talked about automatically dropping context for those disallow rules (to avoid pulling in unused deps when they're not also referenced by the productive parts of the derivation).
Ericson2314 commentedon Oct 15, 2025
For polyfill, content-addressing helps a little bit, because it means the choice of a "real" derivation or built-in derivation doesn't affect output paths.