Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions nixos/lib/eval-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,28 @@ let
};
};

in rec {

# Merge the option definitions in all modules, forming the full
# system configuration.
inherit (lib.evalModules {
noUserModules = lib.evalModules {
inherit prefix check;
modules = baseModules ++ extraModules ++ [ pkgsModule ] ++ modules;
modules = baseModules ++ extraModules ++ [ pkgsModule ];
args = extraArgs;
specialArgs =
{ modulesPath = builtins.toString ../modules; } // specialArgs;
}) config options _module type;
};

# These are the extra arguments passed to every module. In
# particular, Nixpkgs is passed through the "pkgs" argument.
extraArgs = extraArgs_ // {
inherit baseModules extraModules modules;
inherit noUserModules baseModules extraModules modules;
};

in rec {

# Merge the option definitions in all modules, forming the full
# system configuration.
inherit (noUserModules.extendModules { inherit modules; })
config options _module type;

inherit extraArgs;

inherit (_module.args) pkgs;
}
32 changes: 19 additions & 13 deletions nixos/modules/system/activation/top-level.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, lib, pkgs, modules, baseModules, specialArgs, ... }:
{ config, lib, pkgs, extendModules, noUserModules, ... }:

with lib;

Expand All @@ -11,16 +11,10 @@ let
# you can provide an easy way to boot the same configuration
# as you use, but with another kernel
# !!! fix this
children = mapAttrs (childName: childConfig:
(import ../../../lib/eval-config.nix {
inherit lib baseModules specialArgs;
system = config.nixpkgs.initialSystem;
Copy link
Member Author

@roberth roberth Nov 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this to have been insufficient for cross compiled NixOS. (which is fixed by this pr, as mentioned)

modules =
(optionals childConfig.inheritParentConfig modules)
++ [ ./no-clone.nix ]
++ [ childConfig.configuration ];
}).config.system.build.toplevel
) config.specialisation;
children =
mapAttrs
(childName: childConfig: childConfig.configuration.system.build.toplevel)
config.specialisation;

systemBuilder =
let
Expand Down Expand Up @@ -176,7 +170,11 @@ in
</screen>
'';
type = types.attrsOf (types.submodule (
{ ... }: {
local@{ ... }: let
extend = if local.config.inheritParentConfig
then extendModules
else noUserModules.extendModules;
in {
options.inheritParentConfig = mkOption {
type = types.bool;
default = true;
Expand All @@ -185,7 +183,15 @@ in

options.configuration = mkOption {
default = {};
description = "Arbitrary NixOS configuration options.";
description = ''
Arbitrary NixOS configuration.

Anything you can add to a normal NixOS configuration, you can add
here, including imports and config values, although nested
specialisations will be ignored.
'';
visible = "shallow";
inherit (extend { modules = [ ./no-clone.nix ]; }) type;
};
})
);
Expand Down