From ce87196a00214a0062ece1c3e03a9a97f563580f Mon Sep 17 00:00:00 2001 From: K900 Date: Tue, 26 Sep 2023 17:53:40 +0300 Subject: [PATCH] nixos/nixpkgs: assert that nixpkgs.config is not set when pkgs is passed in externally This is a common footgun people hit often. Remove it. --- nixos/modules/misc/nixpkgs.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index f9d8bccea284..1b0434fa7674 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -383,6 +383,16 @@ in the legacy definitions. ''; } + { + assertion = opt.pkgs.isDefined -> cfg.config == {}; + message = '' + Your system configures nixpkgs with an externally created instance. + `nixpkgs.config` options should be passed when creating the instance instead. + + Current value: + ${lib.generators.toPretty { multiline = true; } opt.config} + ''; + } ]; };