2019-04-24 18:24:16 +01: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";
|
2020-05-10 18:41:51 +01:00
|
|
|
example = literalExample "pkgs.device-tree_rpi";
|
2019-05-08 23:25:22 +01:00
|
|
|
type = types.path;
|
2019-04-24 18:24:16 +01:00
|
|
|
description = ''
|
2020-06-21 09:25:52 +01:00
|
|
|
The path containing the base device-tree (.dtb) to boot. Contains
|
2019-04-24 18:24:16 +01:00
|
|
|
device trees bundled with the Linux kernel by default.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-06-21 09:33:09 +01:00
|
|
|
name = mkOption {
|
|
|
|
default = null;
|
|
|
|
example = "some-dtb.dtb";
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = ''
|
|
|
|
The name of an explicit dtb to be loaded, relative to the dtb base.
|
|
|
|
Useful in extlinux scenarios if the bootloader doesn't pick the
|
|
|
|
right .dtb file from FDTDIR.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-04-24 18:24:16 +01:00
|
|
|
overlays = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = literalExample
|
2020-05-10 18:41:51 +01:00
|
|
|
"[\"\${pkgs.device-tree_rpi.overlays}/w1-gpio.dtbo\"]";
|
2019-04-24 18:24:16 +01: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 23:25:22 +01:00
|
|
|
internal = true;
|
2019-04-24 18:24:16 +01:00
|
|
|
description = ''
|
2019-05-08 23:25:22 +01:00
|
|
|
A path containing the result of applying `overlays` to `base`.
|
2019-04-24 18:24:16 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg.enable) {
|
|
|
|
hardware.deviceTree.package = if (cfg.overlays != [])
|
|
|
|
then pkgs.deviceTree.applyOverlays cfg.base cfg.overlays else cfg.base;
|
|
|
|
};
|
|
|
|
}
|