From 2ffb75f9423eb85c4ba5fa043b356f83e0586163 Mon Sep 17 00:00:00 2001 From: Moritz Rumpf Date: Wed, 28 Feb 2024 14:44:09 +0100 Subject: defaults: Add options for dragOnGesture feature This is just a rebased version of https://github.com/LnL7/nix-darwin/pull/513 Credit to @2gn --- modules/system/defaults/NSGlobalDomain.nix | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'modules/system') diff --git a/modules/system/defaults/NSGlobalDomain.nix b/modules/system/defaults/NSGlobalDomain.nix index 4f08d4a..3a18de6 100644 --- a/modules/system/defaults/NSGlobalDomain.nix +++ b/modules/system/defaults/NSGlobalDomain.nix @@ -225,6 +225,14 @@ in { ''; }; + system.defaults.NSGlobalDomain.NSWindowShouldDragOnGesture = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to enable moving window by holding anywhere on it like on Linux. The default is false. + ''; + }; + system.defaults.NSGlobalDomain.InitialKeyRepeat = mkOption { type = types.nullOr types.int; default = null; -- cgit v1.2.3 From ad98aebc0f900fa9bef8dfa8f5bdb328ab93ccd3 Mon Sep 17 00:00:00 2001 From: Moritz Rumpf Date: Wed, 28 Feb 2024 15:02:27 +0100 Subject: Fix doc render problem This fixes: ``` RuntimeError: can't render html in the presence of docbook ``` --- modules/system/defaults/NSGlobalDomain.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/system') diff --git a/modules/system/defaults/NSGlobalDomain.nix b/modules/system/defaults/NSGlobalDomain.nix index 3a18de6..03a7da2 100644 --- a/modules/system/defaults/NSGlobalDomain.nix +++ b/modules/system/defaults/NSGlobalDomain.nix @@ -228,7 +228,7 @@ in { system.defaults.NSGlobalDomain.NSWindowShouldDragOnGesture = mkOption { type = types.nullOr types.bool; default = null; - description = '' + description = lib.mdDoc '' Whether to enable moving window by holding anywhere on it like on Linux. The default is false. ''; }; -- cgit v1.2.3 From 0363c18c3704c44d4a282ecbd1455b325bc37a77 Mon Sep 17 00:00:00 2001 From: Sam <30577766+Samasaur1@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:21:19 -0800 Subject: `system.nvram`: init (internal) --- modules/system/activation-scripts.nix | 1 + modules/system/nvram.nix | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 modules/system/nvram.nix (limited to 'modules/system') 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} + ''; + }; +} -- cgit v1.2.3 From ee53e5785c437aa2e836c6ce3b9fbf3936bf511e Mon Sep 17 00:00:00 2001 From: Sam <30577766+Samasaur1@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:22:41 -0800 Subject: `system.startup.chime`: init --- modules/system/startup.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/system/startup.nix (limited to 'modules/system') 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"); + }; +} -- cgit v1.2.3 From b620e32a761ef6376c1097e73b3f8283604e4982 Mon Sep 17 00:00:00 2001 From: Dylan Frankland Date: Tue, 10 Oct 2023 23:10:58 -0700 Subject: fix writing values with containers Complex container values like `-array` have their own DSL which does not allow specifying all data types. Instead of using the DSL use plist fragments instead. --- modules/system/defaults-write.nix | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'modules/system') diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index 2e56d74..7e1fc44 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -5,18 +5,8 @@ with lib; let cfg = config.system.defaults; - boolValue = x: if x then "YES" else "NO"; - - writeValue = value: - if isBool value then "-bool ${boolValue value}" else - if isInt value then "-int ${toString value}" else - if isFloat value then "-float ${strings.floatToString value}" else - if isString value then "-string '${value}'" else - if isList value then "-array ${concatStringsSep " " (map (v: writeValue v)value)}" else - throw "invalid value type"; - writeDefault = domain: key: value: - "defaults write ${domain} '${key}' ${writeValue value}"; + "defaults write ${domain} '${key}' $'${strings.escape [ "'" ] (generators.toPlist { } value)}'"; defaultsToList = domain: attrs: mapAttrsToList (writeDefault domain) (filterAttrs (n: v: v != null) attrs); -- cgit v1.2.3 From 5c65cfb656c1a7879c750d342bfdcc082831a891 Mon Sep 17 00:00:00 2001 From: Dylan Frankland Date: Mon, 20 Mar 2023 09:22:41 -0700 Subject: Add support for persistent-apps in dock --- modules/system/defaults/dock.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'modules/system') diff --git a/modules/system/defaults/dock.nix b/modules/system/defaults/dock.nix index 7fda0da..9d54f75 100644 --- a/modules/system/defaults/dock.nix +++ b/modules/system/defaults/dock.nix @@ -123,6 +123,19 @@ in { ''; }; + system.defaults.dock.persistent-apps = mkOption { + type = types.nullOr (types.listOf (types.either types.path types.str)); + default = null; + example = [ "/Applications/Safari.app" "/System/Applications/Utilities/Terminal.app" ]; + description = lib.mdDoc '' + Persistent applications in the dock. + ''; + apply = value: + if !(isList value) + then value + else map (app: { tile-data = { file-data = { _CFURLString = app; _CFURLStringType = 0; }; }; }) value; + }; + system.defaults.dock.show-process-indicators = mkOption { type = types.nullOr types.bool; default = null; -- cgit v1.2.3 From 398510f601cb1a1978a393814514f9ca9fbcfe72 Mon Sep 17 00:00:00 2001 From: Malo Bourgon Date: Mon, 25 Mar 2024 16:34:10 -0700 Subject: Add `nix.optimise` module --- modules/system/checks.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'modules/system') diff --git a/modules/system/checks.nix b/modules/system/checks.nix index 27188e3..5989dc4 100644 --- a/modules/system/checks.nix +++ b/modules/system/checks.nix @@ -191,6 +191,17 @@ let exit 2 fi ''; + + nixStoreOptimiser = '' + if test -O /nix/store; then + echo "error: A single-user install can't run optimiser as root, aborting activation" >&2 + echo "Configure the optimiser to run as the current user:" >&2 + echo >&2 + echo " nix.optimiser.user = \"$USER\";" >&2 + echo >&2 + exit 2 + fi + ''; in { @@ -230,6 +241,7 @@ in (mkIf (!config.nix.useDaemon) singleUser) nixStore (mkIf (config.nix.gc.automatic && config.nix.gc.user == null) nixGarbageCollector) + (mkIf (config.nix.optimise.automatic && config.nix.optimise.user == null) nixStoreOptimiser) (mkIf cfg.verifyNixChannels nixChannels) nixInstaller (mkIf cfg.verifyNixPath nixPath) -- cgit v1.2.3