summaryrefslogtreecommitdiffstats
path: root/lib/hardware-notes.nix
blob: 4414ea3914e05b284259ebbfae2bcf7cd69cf4c1 (plain)
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
{ config, lib, pkgs, ... }:

with lib;

let
  # use tail recursion to prevent whitespace padding
  mkLog = list:
    let
      head = builtins.head list;
      tail = builtins.tail list;
    in
    ''
      # ${head.title}
      ${head.text}${if tail == [] then "" else "\n\n${mkLog tail}"}
    '';
in

{

  options = {
    hardwareNotes = mkOption {
      internal = true;
      type = types.listOf types.optionSet;
      options = {
        title = mkOption {
          type = types.str;
          example = "Thunkpad-2000: increase self-destruct timeout";
        };
        text = mkOption {
	  type = types.str;
          example =
            ''
              Increase security timeout at boot using platform managment
              tool to prevent premature data loss.
            '';
        };
      };
    };
  };

  config = {
    environment.etc."hardware-notes".text = mkLog config.hardwareNotes;
  };

}