summary refs log tree commit diff
path: root/nixos/modules/hardware/device-tree.nix
blob: f57502d4c83e9fc1ab12f7575a94571484f63d39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{ 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";
          example = literalExample "pkgs.deviceTree_rpi";
          type = types.path;
          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
            "[\"\${pkgs.deviceTree_rpi.overlays}/w1-gpio.dtbo\"]";
          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;
          internal = true;
          description = ''
            A path containing the result of applying `overlays` to `base`.
          '';
        };
      };
  };

  config = mkIf (cfg.enable) {
    hardware.deviceTree.package = if (cfg.overlays != [])
      then pkgs.deviceTree.applyOverlays cfg.base cfg.overlays else cfg.base;
  };
}