summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2024-04-05 10:59:38 +0200
committerGitHub <noreply@github.com>2024-04-05 10:59:38 +0200
commit6bd39d420578aacf7c0bab7de3e7027b952115ae (patch)
treee84978f345a91441855c396331aee4c68ee77c03 /modules/system
parentd7f1482c47503d6508657ebcbaeef281b78c6c56 (diff)
parent36524adc31566655f2f4d55ad6b875fb5c1a4083 (diff)
Merge branch 'LnL7:master' into master
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/activation-scripts.nix1
-rw-r--r--modules/system/checks.nix12
-rw-r--r--modules/system/defaults-write.nix12
-rw-r--r--modules/system/defaults/NSGlobalDomain.nix8
-rw-r--r--modules/system/defaults/dock.nix13
-rw-r--r--modules/system/nvram.nix40
-rw-r--r--modules/system/startup.nix31
7 files changed, 106 insertions, 11 deletions
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/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)
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);
diff --git a/modules/system/defaults/NSGlobalDomain.nix b/modules/system/defaults/NSGlobalDomain.nix
index 4f08d4a..03a7da2 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 = lib.mdDoc ''
+ 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;
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;
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");
+ };
+}