From a54a799d59f2a4fba2e119e0c42dbe96c2c74a68 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sat, 27 Oct 2018 14:51:54 +0200 Subject: [PATCH] NixOS: nixpkgs.pkgs: Append overlays when specified --- nixos/modules/misc/nixpkgs.nix | 22 ++++++++++++++-------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index 7f9833e184ab..3e9f93b95e64 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -1,9 +1,10 @@ -{ config, lib, pkgs, ... }: +{ config, options, lib, pkgs, ... }: with lib; let cfg = config.nixpkgs; + opt = options.nixpkgs; isConfig = x: builtins.isAttrs x || lib.isFunction x; @@ -54,6 +55,12 @@ let check = builtins.isAttrs; }; + defaultPkgs = import ../../.. { + inherit (cfg) config overlays localSystem crossSystem; + }; + + finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs; + in { @@ -65,9 +72,6 @@ in inherit (cfg) config overlays localSystem crossSystem; } ''; - default = import ../../.. { - inherit (cfg) config overlays localSystem crossSystem; - }; type = pkgsType; example = literalExample ''import {}''; description = '' @@ -128,12 +132,14 @@ in description = '' List of overlays to use with the Nix Packages collection. (For details, see the Nixpkgs documentation.) It allows - you to override packages globally. This is a function that + you to override packages globally. Each function in the list takes as an argument the original Nixpkgs. The first argument should be used for finding dependencies, and the second should be used for overriding recipes. - Ignored when nixpkgs.pkgs is set. + If nixpkgs.pkgs is set, overlays specified here + will be applied after the overlays that were already present + in nixpkgs.pkgs. ''; }; @@ -207,8 +213,8 @@ in config = { _module.args = { - pkgs = cfg.pkgs; - pkgs_i686 = cfg.pkgs.pkgsi686Linux; + pkgs = finalPkgs; + pkgs_i686 = finalPkgs.pkgsi686Linux; }; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 782fb6d8dd89..d0038d8c256f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22091,7 +22091,7 @@ with pkgs; * The result can be extended in the modules by defining * extra options in system.build. * - * Unlike in plain NixOS, the nixpkgs.config, nixpkgs.overlays and + * Unlike in plain NixOS, the nixpkgs.config and * nixpkgs.system options will be ignored by default. Instead, * nixpkgs.pkgs will have the default value of pkgs as it was * constructed right after invoking the nixpkgs function (e.g. the