feat: upgrade overlays to support merging namespaces
This commit is contained in:
parent
8141ee43d8
commit
2bc7d5fab3
5 changed files with 251 additions and 110 deletions
|
|
@ -78,9 +78,10 @@ rec {
|
|||
modules = snowfall-lib.module.create-modules {
|
||||
overrides = (full-flake-options.modules or { });
|
||||
};
|
||||
overlays = core-inputs.flake-utils-plus.lib.exportOverlays ({
|
||||
inherit (user-inputs.self) pkgs inputs;
|
||||
});
|
||||
overlays = snowfall-lib.overlay.create-overlays {
|
||||
overlay-package-namespace = full-flake-options.overlay-package-namespace or null;
|
||||
extra-overlays = full-flake-options.extra-exported-overlays or { };
|
||||
};
|
||||
|
||||
outputs-builder = channels:
|
||||
let
|
||||
|
|
@ -107,7 +108,7 @@ rec {
|
|||
snowfall-lib.attrs.merge-deep [ user-outputs outputs ];
|
||||
|
||||
flake-options = custom-flake-options // {
|
||||
inherit hosts templates overlays;
|
||||
inherit hosts templates;
|
||||
inherit (user-inputs) self;
|
||||
|
||||
lib = snowfall-lib.internal.user-lib;
|
||||
|
|
@ -117,7 +118,7 @@ rec {
|
|||
|
||||
channelsConfig = full-flake-options.channels-config or { };
|
||||
|
||||
channels.nixpkgs.overlaysBuilder = snowfall-lib.overlay.create-overlays {
|
||||
channels.nixpkgs.overlaysBuilder = snowfall-lib.overlay.create-overlays-builder {
|
||||
overlay-package-namespace = full-flake-options.overlay-package-namespace or null;
|
||||
extra-overlays = full-flake-options.overlays or [ ];
|
||||
};
|
||||
|
|
@ -125,36 +126,14 @@ rec {
|
|||
outputsBuilder = outputs-builder;
|
||||
};
|
||||
|
||||
flake-outputs =
|
||||
flake-utils-plus-outputs =
|
||||
core-inputs.flake-utils-plus.lib.mkFlake flake-options;
|
||||
|
||||
overlay = (final: prev:
|
||||
let
|
||||
overlay-package-namespace = full-flake-options.overlay-package-namespace or null;
|
||||
user-overlay-packages =
|
||||
(builtins.map (overlay: overlay final prev) (builtins.attrValues flake-outputs.overlays));
|
||||
namespaced-user-overlay-packages =
|
||||
foldl
|
||||
(namespaced-user-overlay-packages: user-overlay-package:
|
||||
namespaced-user-overlay-packages // user-overlay-package.${overlay-package-namespace}
|
||||
)
|
||||
{ }
|
||||
user-overlay-packages;
|
||||
merged-user-overlay-packages =
|
||||
if overlay-package-namespace == null then
|
||||
snowfall-lib.attrs.merge-shallow
|
||||
user-overlay-packages
|
||||
else
|
||||
{
|
||||
${overlay-package-namespace} =
|
||||
(prev.${overlay-package-namespace} or { })
|
||||
// namespaced-user-overlay-packages;
|
||||
};
|
||||
in
|
||||
merged-user-overlay-packages
|
||||
);
|
||||
flake-outputs =
|
||||
flake-utils-plus-outputs // {
|
||||
inherit overlays;
|
||||
overlay = overlays.default;
|
||||
};
|
||||
in
|
||||
flake-outputs // {
|
||||
inherit overlay;
|
||||
};
|
||||
flake-outputs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue