From b52d80b89873c79f06fce15c30640ed39839221c Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sat, 25 May 2019 13:18:19 +0200 Subject: [PATCH] pkgs.nixos: Expose configuration directly The pkgs.nixos used to only expose system.build, which kind of made sense in theory, but asking everyone to write modules when to want to pull something out of a NixOS configuration is just not realistic. In fact it's very inconvenient when you're trying to debug something. This adds the config, options and anything that eval-config.nix produces. Although this introduces the potential for attributes of eval-config.nix output to shadow system.build, I don't expect naming collisions to be commonplace, or to remain undetected during evaluation. Also such an error should be easy to resolve, by explicitly querying (pkgs.nixos {}).config.system.build.X, or by renaming X to something other than config, options, extraArgs. --- pkgs/top-level/all-packages.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6b76d509ea1..b2439b38771 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23286,6 +23286,8 @@ in initialRamdisk. The result can be extended in the modules by defining extra attributes in system.build. + Alternatively, you may use the result's config and + options attributes to query any option. Example: @@ -23323,10 +23325,13 @@ in Note that you will need to have called Nixpkgs with the system parameter set to the right value for your deployment target. */ - nixos = configuration: - (import (pkgs.path + "/nixos/lib/eval-config.nix") { - inherit (pkgs.stdenv.hostPlatform) system; - modules = [( + nixos = + configuration: + let + c = import (pkgs.path + "/nixos/lib/eval-config.nix") { + inherit (pkgs.stdenv.hostPlatform) system; + modules = + [( { lib, ... }: { config.nixpkgs.pkgs = lib.mkDefault pkgs; } @@ -23335,7 +23340,9 @@ in then configuration else [configuration] ); - }).config.system.build; + }; + in + c.config.system.build // c; /*