Propagate nixpkgs.config to NixOS and HM

This commit is contained in:
Archit Gupta 2024-04-06 17:53:50 -07:00
parent c70ffe0ddd
commit fb530e878f
2 changed files with 12 additions and 5 deletions

View File

@ -954,7 +954,8 @@ or a function that takes `moduleArgs` and returns one of the prior.
When using a set of `nixpkgs.lib.nixosSystem` args, NixOS modules will have When using a set of `nixpkgs.lib.nixosSystem` args, NixOS modules will have
access to a `flake` module arg equivalent to `moduleArgs` plus `inputs'` and access to a `flake` module arg equivalent to `moduleArgs` plus `inputs'` and
`outputs'`. Flakelight's pkgs attributes, `withOverlays`, and `packages` will `outputs'`. Flakelight's pkgs attributes, `withOverlays`, and `packages` will
also be available in the NixOS instance's pkgs. also be available in the NixOS instance's pkgs, and Flakelight's
`nixpkgs.config` will apply to it as well.
When using the result of calling `nixpkgs.lib.nixosSystem`, the When using the result of calling `nixpkgs.lib.nixosSystem`, the
`config.propagationModule` value can be used as a NixOS module to gain the above `config.propagationModule` value can be used as a NixOS module to gain the above

View File

@ -18,10 +18,16 @@ in
config.propagationModule = config.propagationModule =
{ lib, pkgs, options, config, ... }: { lib, pkgs, options, config, ... }:
let inherit (pkgs.stdenv.hostPlatform) system; in { let inherit (pkgs.stdenv.hostPlatform) system; in {
config = (optionalAttrs (options ? nixpkgs.overlays) { config = (optionalAttrs (options ? nixpkgs) {
# Apply flakelight overlays to NixOS/home-manager configurations nixpkgs = (optionalAttrs (options ? nixpkgs.overlays) {
nixpkgs.overlays = lib.mkOrder 10 # Forward overlays to NixOS/home-manager configurations
(flakeConfig.withOverlays ++ [ flakeConfig.packageOverlay ]); overlays = lib.mkOrder 10
(flakeConfig.withOverlays ++ [ flakeConfig.packageOverlay ]);
})
// (optionalAttrs (options ? nixpkgs.config) {
# Forward nixpkgs.config to NixOS/home-manager configurations
inherit (flakeConfig.nixpkgs) config;
});
}) })
// (optionalAttrs (options ? home-manager.sharedModules) { // (optionalAttrs (options ? home-manager.sharedModules) {
# Propagate module to home-manager when using its nixos module # Propagate module to home-manager when using its nixos module