Merge pull request #257458 from K900/die-nixpkgs-config-die

treewide: fail when `nixpkgs.config` is set with explicit `pkgs`, remove all `nixpkgs.config` usages in in-tree modules

K900 eb8ce793 479a4134

Changed files
+59 -63
nixos
doc
manual
modules
hardware
misc
programs
services
desktops
x11
desktop-managers
display-managers
lightdm-greeters
pkgs
applications
display-managers
lightdm-tiny-greeter
servers
x11
tools
misc
mlocate
plocate
top-level
+2 -6
nixos/doc/manual/configuration/customizing-packages.section.md
···
# Customising Packages {#sec-customising-packages}
Some packages in Nixpkgs have options to enable or disable optional
-
functionality or change other aspects of the package. For instance, the
-
Firefox wrapper package (which provides Firefox with a set of plugins
-
such as the Adobe Flash player) has an option to enable the Google Talk
-
plugin. It can be set in `configuration.nix` as follows:
-
`nixpkgs.config.firefox.enableGoogleTalkPlugin = true;`
+
functionality or change other aspects of the package.
::: {.warning}
Unfortunately, Nixpkgs currently lacks a way to query available
···
:::
::: {.note}
-
Alternatively, many packages come with extensions one might add.
+
For example, many packages come with extensions one might add.
Examples include:
- [`passExtensions.pass-otp`](https://search.nixos.org/packages/query=passExtensions.pass-otp)
- [`python310Packages.requests`](https://search.nixos.org/packages/query=python310Packages.requests)
+2
nixos/doc/manual/release-notes/rl-2311.section.md
···
- The `services.mtr-exporter.target` has been removed in favor of `services.mtr-exporter.jobs` which allows specifying multiple targets.
+
- Setting `nixpkgs.config` options while providing an external `pkgs` instance will now raise an error instead of silently ignoring the options. NixOS modules no longer set `nixpkgs.config` to accomodate this. This specifically affects `services.locate`, `services.xserver.displayManager.lightdm.greeters.tiny` and `programs.firefox` NixOS modules. No manual intervention should be required in most cases, however, configurations relying on those modules affecting packages outside the system environment should switch to explicit overlays.
+
## Other Notable Changes {#sec-release-23.11-notable-changes}
- The Cinnamon module now enables XDG desktop integration by default. If you are experiencing collisions related to xdg-desktop-portal-gtk you can safely remove `xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];` from your NixOS configuration.
-3
nixos/modules/hardware/video/amdgpu-pro.nix
···
{
config = mkIf enabled {
-
-
nixpkgs.config.xorg.abiCompat = "1.20";
-
services.xserver.drivers = singleton
{ name = "amdgpu"; modules = [ package ]; display = true; };
+1 -3
nixos/modules/misc/locate.nix
···
plocate = (mkIf isPLocate (mkMerge [ common plocate ]));
};
-
nixpkgs.config = { locate.dbfile = cfg.output; };
-
-
environment.systemPackages = [ cfg.locate ];
+
environment.systemPackages = [ (cfg.locate.override { dbfile = cfg.output; }) ];
environment.variables = mkIf (!isMorPLocate) { LOCATE_PATH = cfg.output; };
+10
nixos/modules/misc/nixpkgs.nix
···
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}
+
'';
+
}
];
};
+1 -1
nixos/modules/programs/browserpass.nix
···
"opt/brave/native-messaging-hosts/${appId}".source = source "hosts/chromium";
"opt/brave/policies/managed/${appId}".source = source "policies/chromium";
};
-
nixpkgs.config.firefox.enableBrowserpass = true;
+
programs.firefox.wrapperConfig.enableBrowserpass = true;
};
}
+20 -8
nixos/modules/programs/firefox.nix
···
];
};
+
wrapperConfig = mkOption {
+
type = types.attrs;
+
default = {};
+
description = mdDoc "Arguments to pass to Firefox wrapper";
+
};
+
policies = mkOption {
type = policyFormat.type;
default = { };
···
] ++ optionals nmh.passff [
passff-host
];
+
cfg = let
+
# copy-pasted from the wrapper; TODO: figure out fix
+
applicationName = cfg.package.binaryName or (lib.getName cfg.package);
+
+
nixpkgsConfig = config.nixpkgs.config.${applicationName} or {};
+
optionConfig = cfg.wrapperConfig;
+
nmhConfig = {
+
enableBrowserpass = nmh.browserpass;
+
enableBukubrow = nmh.bukubrow;
+
enableTridactylNative = nmh.tridactyl;
+
enableUgetIntegrator = nmh.ugetIntegrator;
+
enableFXCastBridge = nmh.fxCast;
+
};
+
in nixpkgsConfig // optionConfig // nmhConfig;
})
];
-
-
nixpkgs.config.firefox = {
-
enableBrowserpass = nmh.browserpass;
-
enableBukubrow = nmh.bukubrow;
-
enableTridactylNative = nmh.tridactyl;
-
enableUgetIntegrator = nmh.ugetIntegrator;
-
enableFXCastBridge = nmh.fxCast;
-
};
environment.etc =
let
+1 -1
nixos/modules/services/desktops/gnome/gnome-browser-connector.nix
···
services.dbus.packages = [ pkgs.gnome-browser-connector ];
-
nixpkgs.config.firefox.enableGnomeExtensions = true;
+
programs.firefox.wrapperConfig.enableGnomeExtensions = true;
};
}
-3
nixos/modules/services/x11/desktop-managers/gnome.nix
···
# Override GSettings schemas
environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
-
-
# If gnome is installed, build vim for gtk3 too.
-
nixpkgs.config.vim.gui = "gtk3";
})
(mkIf flashbackEnabled {
+1 -1
nixos/modules/services/x11/desktop-managers/plasma5.nix
···
# Update the start menu for each user that is currently logged in
system.userActivationScripts.plasmaSetup = activationScript;
-
nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true;
+
programs.firefox.wrapperConfig.enablePlasmaBrowserIntegration = true;
})
(mkIf (cfg.kwinrc != {}) {
+4 -6
nixos/modules/services/x11/display-managers/lightdm-greeters/tiny.nix
···
services.xserver.displayManager.lightdm.greeters.gtk.enable = false;
-
nixpkgs.config.lightdm-tiny-greeter.conf =
+
services.xserver.displayManager.lightdm.greeter =
let
configHeader = ''
#include <gtk/gtk.h>
···
static const char *pass_text = "${cfg.label.pass}";
static const char *session = "${dmcfg.defaultSession}";
'';
+
config = optionalString (cfg.extraConfig != "") (configHeader + cfg.extraConfig);
+
package = pkgs.lightdm-tiny-greeter.override { conf = config; };
in
-
optionalString (cfg.extraConfig != "")
-
(configHeader + cfg.extraConfig);
-
-
services.xserver.displayManager.lightdm.greeter =
mkDefault {
-
package = pkgs.lightdm-tiny-greeter.xgreeters;
+
package = package.xgreeters;
name = "lightdm-tiny-greeter";
};
+1 -1
pkgs/applications/display-managers/lightdm-tiny-greeter/default.nix
···
{ lib, stdenv, linkFarm, lightdm-tiny-greeter, fetchFromGitHub
-
, pkg-config, lightdm, gtk3, glib, wrapGAppsHook, conf ? "" }:
+
, pkg-config, lightdm, gtk3, glib, wrapGAppsHook, config, conf ? config.lightdm-tiny-greeter.conf or "" }:
stdenv.mkDerivation rec {
pname = "lightdm-tiny-greeter";
+12 -19
pkgs/servers/x11/xorg/overrides.nix
···
-
{ abiCompat ? null,
-
callPackage,
+
{ callPackage,
lib, stdenv, makeWrapper, fetchurl, fetchpatch, fetchFromGitLab, buildPackages,
automake, autoconf, libiconv, libtool, intltool, gettext, python3, perl,
freetype, tradcpp, fontconfig, meson, ninja, ed, fontforge,
···
});
xorgserver = with xorg; super.xorgserver.overrideAttrs (attrs_passed:
-
# exchange attrs if abiCompat is set
let
-
version = lib.getVersion attrs_passed;
-
attrs =
-
if (abiCompat == null || lib.hasPrefix abiCompat version) then
-
attrs_passed // {
-
buildInputs = attrs_passed.buildInputs ++
-
lib.optional (libdrm != null) libdrm.dev;
-
postPatch = ''
-
for i in dri3/*.c
-
do
-
sed -i -e "s|#include <drm_fourcc.h>|#include <libdrm/drm_fourcc.h>|" $i
-
done
-
'';
-
meta = attrs_passed.meta // { mainProgram = "X"; };
-
}
-
else throw "unsupported xorg abiCompat ${abiCompat} for ${attrs_passed.name}";
-
+
attrs = attrs_passed // {
+
buildInputs = attrs_passed.buildInputs ++
+
lib.optional (libdrm != null) libdrm.dev;
+
postPatch = ''
+
for i in dri3/*.c
+
do
+
sed -i -e "s|#include <drm_fourcc.h>|#include <libdrm/drm_fourcc.h>|" $i
+
done
+
'';
+
meta = attrs_passed.meta // { mainProgram = "X"; };
+
};
in attrs //
(let
version = lib.getVersion attrs;
+2 -4
pkgs/tools/misc/mlocate/default.nix
···
-
{ lib, stdenv, fetchurl, config }:
+
{ lib, stdenv, fetchurl, config, dbfile ? config.locate.dbfile or "/var/cache/locatedb" }:
-
let
-
dbfile = lib.attrByPath [ "locate" "dbfile" ] "/var/cache/locatedb" config;
-
in stdenv.mkDerivation rec {
+
stdenv.mkDerivation rec {
pname = "mlocate";
version = "0.26";
+1 -3
pkgs/tools/misc/plocate/default.nix
···
, systemd
, liburing
, zstd
+
, dbfile ? config.locate.dbfile or "/var/cache/locatedb"
}:
-
let
-
dbfile = lib.attrByPath [ "locate" "dbfile" ] "/var/cache/locatedb" config;
-
in
stdenv.mkDerivation rec {
pname = "plocate";
version = "1.1.19";
+1 -4
pkgs/top-level/all-packages.nix
···
inherit (buildPackages.darwin) bootstrap_cmds;
udev = if stdenv.isLinux then udev else null;
libdrm = if stdenv.isLinux then libdrm else null;
-
abiCompat = config.xorg.abiCompat or null; # `config` because we have no `xorg.override`
generatedPackages = lib.callPackageWith __splicedPackages ../servers/x11/xorg/default.nix { };
···
lightdm-mobile-greeter = callPackage ../applications/display-managers/lightdm-mobile-greeter { };
-
lightdm-tiny-greeter = callPackage ../applications/display-managers/lightdm-tiny-greeter {
-
conf = config.lightdm-tiny-greeter.conf or "";
-
};
+
lightdm-tiny-greeter = callPackage ../applications/display-managers/lightdm-tiny-greeter { };
ly = callPackage ../applications/display-managers/ly { };