fix(overlay): properly merge namespaced packages

This commit is contained in:
Jake Hamilton 2022-09-09 15:43:18 -07:00
parent 2f1ad83150
commit 8141ee43d8
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68
2 changed files with 24 additions and 27 deletions

View file

@ -4,7 +4,7 @@
}:
let
inherit (core-inputs.nixpkgs.lib) assertMsg fold filterAttrs const;
inherit (core-inputs.nixpkgs.lib) assertMsg foldl filterAttrs const;
in
rec {
flake = rec {
@ -132,23 +132,26 @@ rec {
let
overlay-package-namespace = full-flake-options.overlay-package-namespace or null;
user-overlay-packages =
snowfall-lib.attrs.merge-deep
(builtins.map (overlay: overlay final prev) (builtins.attrValues flake-outputs.overlays));
in
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 if prev ? "${overlay-package-namespace}" then
{
${overlay-package-namespace} =
snowfall-lib.attrs.merge-deep [
prev.${overlay-package-namespace}
user-overlay-packages
];
}
else
{
${overlay-package-namespace} = user-overlay-packages;
}
${overlay-package-namespace} =
(prev.${overlay-package-namespace} or { })
// namespaced-user-overlay-packages;
};
in
merged-user-overlay-packages
);
in
flake-outputs // {

View file

@ -25,7 +25,7 @@ in
user-packages-overlay = final: prev:
let
user-packages = snowfall-lib.package.create-packages {
pkgs = prev;
pkgs = final;
channels = channels;
};
user-packages-without-default = builtins.removeAttrs
@ -33,17 +33,11 @@ in
in
if overlay-package-namespace == null then
user-packages-without-default
else if prev ? "${overlay-package-namespace}" then
{
${overlay-package-namespace} =
snowfall-lib.attrs.merge-deep [
prev.${overlay-package-namespace}
user-packages-without-default
];
}
else
{
${overlay-package-namespace} = user-packages-without-default;
${overlay-package-namespace} =
(prev.${overlay-package-namespace} or { })
// user-packages-without-default;
};
overlays = [ user-packages-overlay ] ++ extra-overlays ++ (builtins.map create-overlay user-overlays);
in