55 lines
1.3 KiB
Nix
55 lines
1.3 KiB
Nix
{ lib, config, ... }:
|
|
let
|
|
inherit (builtins) isAttrs isInt isList isString isFunction isPath length tail head;
|
|
inherit (lib) types;
|
|
listToAttrsOfIndexes_impl = res: idx: list:
|
|
let
|
|
newName = head list;
|
|
in
|
|
assert isAttrs res;
|
|
assert isInt idx;
|
|
assert isList list;
|
|
assert isStringish newName;
|
|
assert !(res ? ${newName}); #no duplicates
|
|
if (length list) == 0 then res
|
|
else
|
|
listToAttrsOfIndexes_impl
|
|
(res // { newName = idx; })
|
|
(idx + 1)
|
|
(tail list)
|
|
;
|
|
listToAttrsOfIndexes = list:
|
|
assert isList list;
|
|
listToAttrsOfIndexes_impl {} 0 list;
|
|
# true iff val can (probably) be interpolated
|
|
isStringish = val:
|
|
isString val || isPath val || (
|
|
isAttrs val &&
|
|
(if val ? __toString then isFunction val.__toString else val ? outPath && isStringish val.outPath)
|
|
)
|
|
;
|
|
in
|
|
{
|
|
imports = [
|
|
./makeWrapper.nix
|
|
./outputOf.nix
|
|
./strings.nix
|
|
];
|
|
|
|
options.vacu.vaculib = lib.mkOption {
|
|
type = types.attrsOf types.anything;
|
|
};
|
|
|
|
config._module.args.vaculib = config.vacu.vaculib;
|
|
|
|
config.vacu.vaculib = {
|
|
mkOutOption = val:
|
|
lib.mkOption {
|
|
readOnly = true;
|
|
default = val;
|
|
}
|
|
;
|
|
inherit listToAttrsOfIndexes isStringish;
|
|
};
|
|
}
|