git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitb52d80b89873c79f06fce15c30640ed39839221c authorRobert Hensing <robert@roberthensing.nl> dateSat 25 May 2019, 13:18 (7 years ago) parent953c81d
1 file changed+12−5
pkgs/top-level/all-packages.nix+12−5
pkgs/top-level/all-packages.nix+12−5
@@ -23286,6 +23286,8 @@ in
2328623286 initialRamdisk.
2328723287 The result can be extended in the modules by defining
2328823288 extra attributes in system.build.
23289+ Alternatively, you may use the result's config and
23290+ options attributes to query any option.
2328923291
2329023292 Example:
2329123293
@@ -23323,10 +23325,13 @@ in
2332323325 Note that you will need to have called Nixpkgs with the system
2332423326 parameter set to the right value for your deployment target.
2332523327 */
23326− nixos = configuration:
23327− (import (pkgs.path + "/nixos/lib/eval-config.nix") {
23328− inherit (pkgs.stdenv.hostPlatform) system;
23329− modules = [(
23328+ nixos =
23329+ configuration:
23330+ let
23331+ c = import (pkgs.path + "/nixos/lib/eval-config.nix") {
23332+ inherit (pkgs.stdenv.hostPlatform) system;
23333+ modules =
23334+ [(
2333023335 { lib, ... }: {
2333123336 config.nixpkgs.pkgs = lib.mkDefault pkgs;
2333223337 }
@@ -23335,7 +23340,9 @@ in
2333523340 then configuration
2333623341 else [configuration]
2333723342 );
23338− }).config.system.build;
23343+ };
23344+ in
23345+ c.config.system.build // c;
2333923346
2334023347
2334123348 /*