I am trying to package something as a Nix flake that requires network block devices to be enabled.
I can see that this setting can be enabled by setting programs.nbd.enable = true;.
My question is - is there a way of configuring the Flake so nix build will temporarily enable this setting to build the package, rather than requiring everyone to change their NixOS configuration in order to build the package?
You have a derivation that requires a certain system feature to be availabe. This feature can be provided on NixOS by enabling a certain option and on other linuxes by other means.
So the correct thing would probably be to add a requiredSystemFeatures with “ndb” or something, and ask your consumers to provide that feature and tell nix that the feature is available via the system-features setting.
As you have a flake, you could create a module doing that, which you also expose.
On the other hand though, why is that required? And is this actually required for the build, or at runtime only?
As far as I remember, the sandbox shouldn’t have access to /dev anyway…
I guess then it would be possible to supply a VM configuration for consumers to use using the above module.
On the other hand though, why is that required? And is this actually required for the build, or at runtime only?
This is a valid point. The source code (GitHub - RPi-Distro/pi-gen: Tool used to create the official Raspberry Pi OS images) I’m trying to put into a derivation normally expects to be run in a Debian environment and uses nbds to incrementally build a Raspberry Pi OS image. I was trying to avoid having to change the source too dramatically just to build it in a nix derivation, but it sounds like it might require significant changes to get it built properly.