oom-hardware/uconsole/packages/overlays/default.nix
2024-10-17 15:00:31 +02:00

52 lines
1.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib; let
overlayParamsType = types.submodule {
options = {
name = mkOption {
type = types.str;
description = lib.mdDoc ''
Name of an overlay for which params are going to be passed to dtmerge.
'';
};
params = mkOption {
type = types.attrsOf types.str;
description = lib.mdDoc ''
Params to pass to dtmerge.
'';
};
};
};
paramsPerOverlayMap =
builtins.mapAttrs
(_: value: builtins.foldl' (a: b: a // b) {} (builtins.catAttrs "params" value))
(builtins.groupBy (x: x.name) config.hardware.deviceTree.overlaysParams);
dtmergeOverlay = _final: prev: {
deviceTree =
prev.deviceTree
// {
applyOverlays = _final.callPackage ((import ./apply-overlays-dtmerge.nix) paramsPerOverlayMap) {};
};
};
in {
options = {
hardware.deviceTree.overlaysParams = mkOption {
default = [];
type = types.listOf overlayParamsType;
};
};
config = {
nixpkgs.overlays = [
dtmergeOverlay
];
};
}