Passing additional attributes to trivial builders

Hello all,

I’m attempting to get all of my organization’s nix derivations building remotely, on a specific build server. To facilitate this, I’ve been going through the derivations and adding requiredSystemFeatures = [ "our_org_name" ]; to the derivations, (as described here: Remote Builds - Nix Reference Manual, although, this question could apply to any generic derivation setting, like enableParallelBuilding).

Some of the derivations we are using are trivial builders (either defined by ourselves, or as part of third-party derivations), like runCommand. Is there a way to have these also built remotely? There is no obvious way to have them use the requiredSystemFeatures setting. If they are our own, they can be re-written as derivations, but if third-party this is a little more complex.

In case anyone else needs this, the solution I’m using for this is to create the package using a trivial builder, then use overrideAttrs (Nixpkgs 22.11 manual | Nix & NixOS) to set the required attributes. So:

let buildOnBuildServer = pkg:
  let buildRemotelyOverride = prev: {
      enableParallelBuilding = true;
      requiredSystemFeatures = [ "our_org_name" ];
    in pkg.overrideAttrs buildRemotelyOverride;
in some_pkg = buildOnBuildServer (callPackage ./some_pkg.nix {});