Merge pull request #260770 from hercules-ci/darwin-builder-observable

`darwin.linux-builder`: Make more observable

Changed files
+21 -1
doc
builders
nixos
modules
+14
doc/builders/special/darwin-builder.section.md
···
You may make any other changes to your VM in this attribute set. For example,
you could enable Docker or X11 forwarding to your Darwin host.
···
You may make any other changes to your VM in this attribute set. For example,
you could enable Docker or X11 forwarding to your Darwin host.
+
## Troubleshooting the generated configuration {#sec-darwin-builder-troubleshoot}
+
+
The `linux-builder` package exposes the attributes `nixosConfig` and `nixosOptions` that allow you to inspect the generated NixOS configuration in the `nix repl`. For example:
+
+
```
+
$ nix repl --file ~/src/nixpkgs --argstr system aarch64-darwin
+
+
nix-repl> darwin.linux-builder.nixosConfig.nix.package
+
«derivation /nix/store/...-nix-2.17.0.drv»
+
+
nix-repl> :p darwin.linux-builder.nixosOptions.virtualisation.memorySize.definitionsWithLocations
+
[ { file = "/home/user/src/nixpkgs/nixos/modules/profiles/macos-builder.nix"; value = 3072; } ]
+
+
```
+7 -1
nixos/modules/profiles/macos-builder.nix
···
-
{ config, lib, ... }:
let
keysDirectory = "/var/keys";
···
in
script.overrideAttrs (old: {
meta = (old.meta or { }) // {
platforms = lib.platforms.darwin;
};
});
···
+
{ config, lib, options, ... }:
let
keysDirectory = "/var/keys";
···
in
script.overrideAttrs (old: {
+
pos = __curPos; # sets meta.position to point here; see script binding above for package definition
meta = (old.meta or { }) // {
platforms = lib.platforms.darwin;
+
};
+
passthru = (old.passthru or { }) // {
+
# Let users in the repl inspect the config
+
nixosConfig = config;
+
nixosOptions = options;
};
});