8.nix-darwin/modules
Robert Hensing acf6b46011 system.build: Treat as variables, make lazy
This fixes an unnecessary evaluation dependency that prevented the
custom and much appreciated primaryUser error from popping up.

Specifically:

       … while evaluating the option `system.build':

       … while evaluating definitions from `/nix/store/lc6n4bhxj9255kzfn9pnpx65583a8cgc-source/modules/environment':

       … while evaluating definitions from `/nix/store/lc6n4bhxj9255kzfn9pnpx65583a8cgc-source/modules/nix':

       … while evaluating the option `environment.darwinConfig':

       … while evaluating the option `system.primaryUserHome':

       error: expected a string but found null: null
       at /nix/store/lc6n4bhxj9255kzfn9pnpx65583a8cgc-source/modules/system/primary-user.nix:26:30:
           25|       default =
           26|         config.users.users.${config.system.primaryUser}.home or "/Users/${config.system.primaryUser}";
             |                              ^
           27|     };

While it did have some indication as to the cause, it lets the good
error message go to waste.

**Context**

`lazyAttrsOf` is the better choice when you use an attrset as individual
variables instead of in aggregate (e.g. `attrNames`, `toJSON`).

The reason is that an expression like `a.b` is strict in `a`, which
entails the evaluating the _whole_ set of attribute _names_ in `a`.
In the `attrsOf` this means evaluating all `mkIf` conditions, which
in turn also means evaluating all the regular definitions to the
smallest degree (WHNF) to determine that they're not `mkIf`s.

`lazyAttrsOf` simply assumes that all attributes aren't `mkIf false`,
and throws an error in the attribute value if necessary.
This would be a problem with `toJSON` and such, but is completely
fine when the attributes are treated as variables of a lazy program,
as is the case here.

**NixOS**

NixOS made `system.build` a submodule with a `freeformType`, allowing
the things inside of it to be declared, and for them to have niceties
like documentation and merging behavior.
nix-darwin could probably adopt this.
2025-05-23 12:00:51 +02:00
..
documentation Reapply "eval-config: set class" 2024-06-13 14:35:20 +01:00
environment {environment,nix}: remove references to $HOME 2025-05-16 16:31:17 +01:00
examples launchd: move userLaunchd to system activation 2025-05-16 16:29:17 +01:00
fonts fonts: remove fonts.fontDir.enable 2024-06-13 11:56:58 +01:00
launchd launchd: move userLaunchd to system activation 2025-05-16 16:29:17 +01:00
lib write-text: remove support for copy 2024-06-15 12:15:13 +01:00
misc services/dnscrypt-proxy: init 2025-02-28 19:58:19 +07:00
networking networking: allow users to override FQDN 2025-04-28 14:22:30 +10:00
nix etc: merge etcChecks into checks 2025-05-16 16:34:31 +01:00
power power: move the check for restartPowerfailure support to checks.nix 2024-12-29 12:13:54 +01:00
programs _1password{,-gui}: fix package not being used 2025-05-15 17:01:26 +10:00
security pam: add pam_watchid support 2025-02-25 23:51:30 +08:00
services feat(services.openssh): add extraConfig option 2025-05-22 20:22:47 +02:00
system system.build: Treat as variables, make lazy 2025-05-23 12:00:51 +02:00
time time: shellcheck fix 2024-11-05 11:12:21 +10:00
users activation-scripts: get rid of user activation 2025-05-16 16:34:31 +01:00
alias.nix Update def and implementation of nix.package to match NixOS module 2022-08-16 10:41:51 -07:00
homebrew.nix homebrew: move to system activation 2025-05-16 16:29:17 +01:00
meta.nix treewide: remove lib.mdDoc 2024-04-19 04:05:50 +02:00
module-list.nix primary-user: init 2025-05-16 16:29:17 +01:00