diff options
| author | Michael Hoang <Enzime@users.noreply.github.com> | 2024-03-02 13:57:42 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-02 13:57:42 +1100 |
| commit | 8a15cb36fffa0b5fbe31ef16ede0a479bef4b365 (patch) | |
| tree | d8953b84f4c0323697c4de2e5c2486f0e392346b | |
| parent | 70d162d4684f738761ab4251c0cee05b5f5d4d53 (diff) | |
| parent | ee53e5785c437aa2e836c6ce3b9fbf3936bf511e (diff) | |
Merge pull request #892 from Samasaur1/startup-chime
`system.startup.chime`: init
| -rw-r--r-- | modules/module-list.nix | 2 | ||||
| -rw-r--r-- | modules/system/activation-scripts.nix | 1 | ||||
| -rw-r--r-- | modules/system/nvram.nix | 40 | ||||
| -rw-r--r-- | modules/system/startup.nix | 31 |
4 files changed, 74 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix index 053b0a9..043d1ee 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -35,8 +35,10 @@ ./system/etc.nix ./system/keyboard.nix ./system/launchd.nix + ./system/nvram.nix ./system/patches.nix ./system/shells.nix + ./system/startup.nix ./system/version.nix ./time ./networking diff --git a/modules/system/activation-scripts.nix b/modules/system/activation-scripts.nix index 67d69be..68e01b5 100644 --- a/modules/system/activation-scripts.nix +++ b/modules/system/activation-scripts.nix @@ -69,6 +69,7 @@ in ${cfg.activationScripts.networking.text} ${cfg.activationScripts.keyboard.text} ${cfg.activationScripts.fonts.text} + ${cfg.activationScripts.nvram.text} ${cfg.activationScripts.postActivation.text} diff --git a/modules/system/nvram.nix b/modules/system/nvram.nix new file mode 100644 index 0000000..efc9c99 --- /dev/null +++ b/modules/system/nvram.nix @@ -0,0 +1,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} + ''; + }; +} diff --git a/modules/system/startup.nix b/modules/system/startup.nix new file mode 100644 index 0000000..ecbef46 --- /dev/null +++ b/modules/system/startup.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.system.startup; +in + +{ + meta.maintainers = [ + lib.maintainers.samasaur or "samasaur" + ]; + + options = { + system.startup.chime = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = false; + description = lib.mdDoc '' + Whether to enable the startup chime. + + By default, this option does not affect your system configuration in any way. + However, this means that after it has been set once, unsetting it will not + return to the old behavior. It will allow the setting to be controlled in + System Settings, though. + ''; + }; + }; + + config = { + system.nvram.variables."StartupMute" = lib.mkIf (cfg.chime != null) (if cfg.chime then "%00" else "%01"); + }; +} |
