2019-04-24 17:24:16 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.hardware.deviceTree;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
hardware.deviceTree = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = pkgs.stdenv.hostPlatform.platform.kernelDTB or false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Build device tree files. These are used to describe the
|
|
|
|
non-discoverable hardware of a system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
base = mkOption {
|
|
|
|
default = "${config.boot.kernelPackages.kernel}/dtbs";
|
|
|
|
defaultText = "\${config.boot.kernelPackages.kernel}/dtbs";
|
2019-05-08 22:25:22 +00:00
|
|
|
example = literalExample "pkgs.deviceTree_rpi";
|
|
|
|
type = types.path;
|
2019-04-24 17:24:16 +00:00
|
|
|
description = ''
|
|
|
|
The package containing the base device-tree (.dtb) to boot. Contains
|
|
|
|
device trees bundled with the Linux kernel by default.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
overlays = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = literalExample
|
2019-05-08 22:25:22 +00:00
|
|
|
"[\"\${pkgs.deviceTree_rpi.overlays}/w1-gpio.dtbo\"]";
|
2019-04-24 17:24:16 +00:00
|
|
|
type = types.listOf types.path;
|
|
|
|
description = ''
|
|
|
|
A path containing device tree overlays (.dtbo) to be applied to all
|
|
|
|
base device-trees.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
2019-05-08 22:25:22 +00:00
|
|
|
internal = true;
|
2019-04-24 17:24:16 +00:00
|
|
|
description = ''
|
2019-05-08 22:25:22 +00:00
|
|
|
A path containing the result of applying `overlays` to `base`.
|
2019-04-24 17:24:16 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg.enable) {
|
|
|
|
hardware.deviceTree.package = if (cfg.overlays != [])
|
|
|
|
then pkgs.deviceTree.applyOverlays cfg.base cfg.overlays else cfg.base;
|
|
|
|
};
|
|
|
|
}
|