From 962eb3f1c0c2d5e4ac92eb8bfc91333d3b1cb0e7 Mon Sep 17 00:00:00 2001 From: Emily Date: Mon, 3 Feb 2025 19:29:03 +0000 Subject: [PATCH] nixpkgs: assert that nixpkgs.config is not set when pkgs is passed in externally This is a common footgun people hit often. Remove it. Backport of Nixpkgs commit ce87196a00214a0062ece1c3e03a9a97f563580f. Co-authored-by: K900 --- modules/nix/nixpkgs.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/nix/nixpkgs.nix b/modules/nix/nixpkgs.nix index 511d718..2ed7b8d 100644 --- a/modules/nix/nixpkgs.nix +++ b/modules/nix/nixpkgs.nix @@ -300,6 +300,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} + ''; + } ]; }; }