From c70ffe0dddd2540e428e0c3d67339fc7ce3b6793 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Sat, 6 Apr 2024 17:47:55 -0700 Subject: [PATCH] Check HM useGlobalPkgs before propagating The NixOS home-manager module only uses nixpkgs settings if useGlobalPkgs is false. If it is true, there is no need to propagate config (and propagating nixpkgs.config would cause an assertion). --- builtinModules/propagationModule.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/builtinModules/propagationModule.nix b/builtinModules/propagationModule.nix index e5c4c43..6f49a4c 100644 --- a/builtinModules/propagationModule.nix +++ b/builtinModules/propagationModule.nix @@ -7,24 +7,27 @@ { lib, config, flakelight, moduleArgs, inputs, outputs, ... }: let - inherit (lib) mapAttrs mkOption optionalAttrs; + inherit (lib) mapAttrs mkOption optional optionalAttrs; inherit (flakelight) selectAttr; inherit (flakelight.types) module; + flakeConfig = config; in { options.propagationModule = mkOption { type = module; internal = true; }; config.propagationModule = - { lib, pkgs, options, ... }: + { lib, pkgs, options, config, ... }: let inherit (pkgs.stdenv.hostPlatform) system; in { config = (optionalAttrs (options ? nixpkgs.overlays) { # Apply flakelight overlays to NixOS/home-manager configurations nixpkgs.overlays = lib.mkOrder 10 - (config.withOverlays ++ [ config.packageOverlay ]); + (flakeConfig.withOverlays ++ [ flakeConfig.packageOverlay ]); }) // (optionalAttrs (options ? home-manager.sharedModules) { # Propagate module to home-manager when using its nixos module - home-manager.sharedModules = [ config.propagationModule ]; + home-manager.sharedModules = + optional (! config.home-manager.useGlobalPkgs) + [ flakeConfig.propagationModule ]; }) // { # Give access to flakelight module args under `flake` arg.