pkgs/den-update-script: init

This commit is contained in:
Wroclaw 2025-03-18 18:09:26 +01:00
parent 3fb3b7771f
commit 7ec22b6e52

View file

@ -0,0 +1,39 @@
{
lib,
path,
overlayAttrname ? "den-outputs",
}:
assert lib.assertMsg (!lib.hasInfix "." overlayAttrname) (lib.pipe ''
overlayAttrname must not contain a dot (.),
because dot is used to reference package in a package set
inside nix-update-script.
'' [
lib.lines
(lib.concatStringsSep " ")
]);
let
updateScript = import (path + /maintainers/scripts/update.nix);
functionArgs = lib.functionArgs updateScript;
nameInFunctionArgs = name: lib.elem name (lib.attrNames functionArgs);
in
{
__functionArgs = functionArgs // { packages = false; };
__functor = _: args: let
# args.outputs should be an attrset of packages to update
overlay = _: _: {
"${overlayAttrname}" = args.packages;
};
in updateScript (lib.filterAttrs (name: _: nameInFunctionArgs name) args // {
include-overlays =
if !args ? updateScript then [ overlay ]
else if lib.isList args.updateScript then [ overlay ] ++ args.updateScript
else args.updateScript;
} // lib.optionalAttrs (args ? package) {
package = "${overlayAttrname}.${args.package}";
} // lib.optionalAttrs (args ? path) {
path = if lib.stringLength args.path == 0 then overlayAttrname else "${overlayAttrname}.${args.path}";
});
}