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

View file

@ -25,7 +25,7 @@ in
user-packages-overlay = final: prev: user-packages-overlay = final: prev:
let let
user-packages = snowfall-lib.package.create-packages { user-packages = snowfall-lib.package.create-packages {
pkgs = prev; pkgs = final;
channels = channels; channels = channels;
}; };
user-packages-without-default = builtins.removeAttrs user-packages-without-default = builtins.removeAttrs
@ -33,17 +33,11 @@ in
in in
if overlay-package-namespace == null then if overlay-package-namespace == null then
user-packages-without-default 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 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); overlays = [ user-packages-overlay ] ++ extra-overlays ++ (builtins.map create-overlay user-overlays);
in in