9 cfg = config.hardware.rasdaemon;
13 options.hardware.rasdaemon = {
15 enable = lib.mkEnableOption "RAS logging daemon";
17 record = lib.mkOption {
18 type = lib.types.bool;
20 description = "record events via sqlite3, required for ras-mc-ctl";
23 mainboard = lib.mkOption {
24 type = lib.types.lines;
26 description = "Custom mainboard description, see {manpage}`ras-mc-ctl(8)` for more details.";
31 # it should default to such values from
32 # /sys/class/dmi/id/board_[vendor|name]
33 # alternatively one can supply a script
34 # that returns the same format as above
36 script = <path to script>
40 # TODO, accept `rasdaemon.labels = " ";` or `rasdaemon.labels = { dell = " "; asrock = " "; };'
42 labels = lib.mkOption {
43 type = lib.types.lines;
45 description = "Additional memory module label descriptions to be placed in /etc/ras/dimm_labels.d/labels";
47 # vendor and model may be shown by 'ras-mc-ctl --mainboard'
49 product: To Be Filled By O.E.M.
51 # these labels are names for the motherboard slots
52 # the numbers may be shown by `ras-mc-ctl --error-count`
53 # they are mc:csrow:channel
54 DDR4_A1: 0.2.0; DDR4_B1: 0.2.1;
55 DDR4_A2: 0.3.0; DDR4_B2: 0.3.1;
59 config = lib.mkOption {
60 type = lib.types.lines;
63 rasdaemon configuration, currently only used for CE PFA
64 for details, read rasdaemon.outPath/etc/sysconfig/rasdaemon's comments
67 # defaults from included config
68 PAGE_CE_REFRESH_CYCLE="24h"
69 PAGE_CE_THRESHOLD="50"
74 extraModules = lib.mkOption {
75 type = lib.types.listOf lib.types.str;
77 description = "extra kernel modules to load";
78 example = [ "i7core_edac" ];
81 testing = lib.mkEnableOption "error injection infrastructure";
84 config = lib.mkIf cfg.enable {
88 enable = cfg.mainboard != "";
91 # TODO, handle multiple cfg.labels.brand = " ";
92 "ras/dimm_labels.d/labels" = {
93 enable = cfg.labels != "";
96 "sysconfig/rasdaemon" = {
97 enable = cfg.config != "";
101 environment.systemPackages =
103 ++ lib.optionals (cfg.testing) (
104 with pkgs.error-inject;
112 boot.initrd.kernelModules =
114 ++ lib.optionals (cfg.testing) [
115 # edac_core and amd64_edac should get loaded automatically
116 # i7core_edac may not be, and may not be required, but should load successfully
124 boot.kernelPatches = lib.optionals (cfg.testing) [
126 name = "rasdaemon-tests";
139 # i tried to set up a group for this
140 # but rasdaemon needs higher permissions?
141 # `rasdaemon: Can't locate a mounted debugfs`
143 # most of this taken from src/misc/
146 description = "the RAS logging daemon";
147 documentation = [ "man:rasdaemon(1)" ];
148 wantedBy = [ "multi-user.target" ];
151 StateDirectory = lib.optionalString (cfg.record) "rasdaemon";
154 "${pkgs.rasdaemon}/bin/rasdaemon --foreground" + lib.optionalString (cfg.record) " --record";
155 ExecStop = "${pkgs.rasdaemon}/bin/rasdaemon --disable";
156 Restart = "on-abort";
158 # src/misc/rasdaemon.service.in shows this:
159 # ExecStartPost = ${pkgs.rasdaemon}/bin/rasdaemon --enable
160 # but that results in unpredictable existence of the database
161 # and everything seems to be enabled without this...
164 ras-mc-ctl = lib.mkIf (cfg.labels != "") {
165 description = "register DIMM labels on startup";
166 documentation = [ "man:ras-mc-ctl(8)" ];
167 wantedBy = [ "multi-user.target" ];
170 ExecStart = "${pkgs.rasdaemon}/bin/ras-mc-ctl --register-labels";
171 RemainAfterExit = true;
177 meta.maintainers = [ lib.maintainers.evils ];