···101101 else
102102 throw "cannot find nix-darwin input";
103103104104+ # create the modulesPath based on the system, we need
105105+ modulesPath =
106106+ if class == "darwin" then "${darwinInput}/modules" else "${inputs.nixpkgs}/nixos/modules";
107107+108108+ # we need to import the module list for our system
109109+ # this is either the nixos modules list provided by nixpkgs
110110+ # or the darwin modules list provided by nix darwin
111111+ baseModules = import "${modulesPath}/module-list.nix";
112112+104113 eval = evalModules {
105114 # we use recursiveUpdate such that users can "override" the specialArgs
106115 #
107116 # This should only be used for special arguments that need to be evaluated
108117 # when resolving module structure (like in imports).
109118 specialArgs = recursiveUpdate {
110110- # create the modulesPath based on the system, we need
111111- modulesPath =
112112- if class == "darwin" then "${darwinInput}/modules" else "${inputs.nixpkgs}/nixos/modules";
119119+ inherit
120120+ # these are normal args that people expect to be passed
121121+ lib
122122+ self # even though self is just the same as `inputs.self`
123123+ inputs
124124+125125+ # these come from flake-parts
126126+ self'
127127+ inputs'
113128114114- # laying it out this way is completely arbitrary, however it looks nice i guess
115115- inherit lib;
116116- inherit self self';
117117- inherit inputs inputs';
129129+ # we need to set this beacuse some modules require it sadly
130130+ # you may also recall `modulesPath + /installer/scan/not-detected.nix`
131131+ modulesPath
132132+ ;
118133 } specialArgs;
119134120135 # A nominal type for modules. When set and non-null, this adds a check to
···122137 class = classToND class;
123138124139 modules = flatten [
140140+ # bring in all of our base modules
141141+ baseModules
142142+125143 # import our host system paths
126144 (
127145 if path != null then
···140158 "${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix"
141159 ])
142160143143- # we need to import the module list for our system
144144- # this is either the nixos modules list provided by nixpkgs
145145- # or the darwin modules list provided by nix darwin
146146- (import (
147147- if class == "darwin" then
148148- "${darwinInput}/modules/module-list.nix"
149149- else
150150- "${inputs.nixpkgs}/nixos/modules/module-list.nix"
151151- ))
152152-153161 (singleton {
154154- # TODO: learn what this means and why its needed to build the iso
155155- _module.args.modules = [ ];
162162+ # some modules to have these arguments, like documentation.nix
163163+ # <https://github.com/NixOS/nixpkgs/blob/9692553cb583e8dca46b66ab76c0eb2ada1a4098/nixos/modules/misc/documentation.nix>
164164+ _module.args = {
165165+ inherit baseModules;
166166+167167+ # this should in the future be the modules that the user added without baseModules
168168+ modules = [ ];
169169+170170+ # TODO: remove in 25.05
171171+ # https://github.com/NixOS/nixpkgs/blob/9692553cb583e8dca46b66ab76c0eb2ada1a4098/nixos/lib/eval-config.nix#L38
172172+ extraModules = [ ];
173173+ };
156174157175 # we set the systems hostname based on the host value
158176 # which should be a string that is the hostname of the system
···236254 )
237255 );
238256239239- onlyDirs = filterAttrs (_: type: type == "directory");
240240-241257 normaliseHosts =
242258 cfg: hosts:
243259 if (cfg.onlySystem == null) then
···281297 if (cfg.onlySystem != null) then
282298 hostsDir
283299 else
284284- mapAttrs (path: _: readDir "${cfg.path}/${path}") (onlyDirs hostsDir);
300300+ mapAttrs (path: _: readDir "${cfg.path}/${path}") (
301301+ filterAttrs (_: type: type == "directory") hostsDir
302302+ );
285303 in
286304 normaliseHosts cfg hosts;
287305in