summaryrefslogtreecommitdiff
path: root/modules/system/nvram.nix
blob: efc9c9980725cc8b56961338d2178f82ae43afd9 (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
{ config, lib, pkgs, ... }:

let
  cfg = config.system;

  mkNvramVariables =
    lib.attrsets.mapAttrsToList
      (name: value: "nvram ${lib.escapeShellArg name}=${lib.escapeShellArg value}")
      cfg.nvram.variables;
in

{
  meta.maintainers = [
    lib.maintainers.samasaur or "samasaur"
  ];

  options = {
    system.nvram.variables = lib.mkOption {
      type = with lib.types; attrsOf str;
      default = {};
      internal = true;
      example = {
        "StartupMute" = "%01";
      };
      description = lib.mdDoc ''
        Non-volatile RAM variables to set. Removing a key-value pair from this
        list will **not** return the variable to its previous value, but will
        no longer set its value on system configuration activations.
      '';
    };
  };

  config = {
    system.activationScripts.nvram.text = ''
      echo "setting nvram variables..." >&2

      ${builtins.concatStringsSep "\n" mkNvramVariables}
    '';
  };
}