summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-12-14 13:05:23 +0100
committerDaiderd Jordan <daiderd@gmail.com>2016-12-14 13:05:23 +0100
commita48cc8ac5f6cda041def73e9564325e5b0ed6633 (patch)
tree6fb9ff45adf8846440a4ea28bb45150025bd7a46 /modules
parent6af52615ed8de2c4f9f4a30d97a22f7b3513c474 (diff)
move system.defaults to separate files
Diffstat (limited to 'modules')
-rw-r--r--modules/system/defaults-write.nix48
-rw-r--r--modules/system/defaults/LaunchServices.nix14
-rw-r--r--modules/system/defaults/NSGlobalDomain.nix19
-rw-r--r--modules/system/defaults/default.nix31
-rw-r--r--modules/system/defaults/dock.nix14
-rw-r--r--modules/system/defaults/finder.nix14
-rw-r--r--modules/system/defaults/trackpad.nix14
7 files changed, 123 insertions, 31 deletions
diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix
new file mode 100644
index 0000000..7ad97da
--- /dev/null
+++ b/modules/system/defaults-write.nix
@@ -0,0 +1,48 @@
+{ config, lib, ... }:
+
+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 isString value then "-string '${value}'" else
+ throw "invalid value type";
+
+ writeDefault = domain: key: value:
+ "defaults write ${domain} '${key}' ${writeValue value}";
+
+ defaultsToList = domain: attrs: mapAttrsToList (writeDefault domain) (filterAttrs (n: v: v != null) attrs);
+
+ NSGlobalDomain = defaultsToList "-g" cfg.NSGlobalDomain;
+ LaunchServices = defaultsToList "com.apple.LaunchServices" cfg.LaunchServices;
+ dock = defaultsToList "com.apple.dock" cfg.dock;
+ finder = defaultsToList "com.apple.finder" cfg.finder;
+ trackpad = defaultsToList "com.apple.driver.AppleBluetoothMultitouch.trackpad" cfg.trackpad;
+
+in
+
+{
+ options = {
+ };
+
+ config = {
+
+ system.activationScripts.defaults.text = ''
+ # Set defaults
+ echo "writing defaults..." >&2
+
+ ${concatStringsSep "\n" NSGlobalDomain}
+ ${concatStringsSep "\n" LaunchServices}
+ ${concatStringsSep "\n" dock}
+ ${concatStringsSep "\n" finder}
+ ${concatStringsSep "\n" trackpad}
+ '';
+
+ };
+}
diff --git a/modules/system/defaults/LaunchServices.nix b/modules/system/defaults/LaunchServices.nix
new file mode 100644
index 0000000..0ab5ca9
--- /dev/null
+++ b/modules/system/defaults/LaunchServices.nix
@@ -0,0 +1,14 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+ options = {
+
+ system.defaults.LaunchServices.LSQuarantine = mkOption {
+ type = types.nullOr types.bool;
+ default = null;
+ };
+
+ };
+}
diff --git a/modules/system/defaults/NSGlobalDomain.nix b/modules/system/defaults/NSGlobalDomain.nix
new file mode 100644
index 0000000..ed78a7c
--- /dev/null
+++ b/modules/system/defaults/NSGlobalDomain.nix
@@ -0,0 +1,19 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+ options = {
+
+ system.defaults.NSGlobalDomain.InitialKeyRepeat = mkOption {
+ type = types.nullOr types.int;
+ default = null;
+ };
+
+ system.defaults.NSGlobalDomain.KeyRepeat = mkOption {
+ type = types.nullOr types.int;
+ default = null;
+ };
+
+ };
+}
diff --git a/modules/system/defaults/default.nix b/modules/system/defaults/default.nix
index 6d472fe..0f9877d 100644
--- a/modules/system/defaults/default.nix
+++ b/modules/system/defaults/default.nix
@@ -27,37 +27,6 @@ in
{
options = {
-
- system.defaults.global.InitialKeyRepeat = mkOption {
- type = types.nullOr types.int;
- default = null;
- };
-
- system.defaults.global.KeyRepeat = mkOption {
- type = types.nullOr types.int;
- default = null;
- };
-
- system.defaults.dock.autohide = mkOption {
- type = types.nullOr types.bool;
- default = null;
- };
-
- system.defaults.finder.AppleShowAllExtensions = mkOption {
- type = types.nullOr types.bool;
- default = null;
- };
-
- system.defaults.trackpad.Clicking = mkOption {
- type = types.nullOr types.bool;
- default = null;
- };
-
- system.defaults.LaunchServices.LSQuarantine = mkOption {
- type = types.nullOr types.bool;
- default = null;
- };
-
};
config = {
diff --git a/modules/system/defaults/dock.nix b/modules/system/defaults/dock.nix
new file mode 100644
index 0000000..f40087b
--- /dev/null
+++ b/modules/system/defaults/dock.nix
@@ -0,0 +1,14 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+ options = {
+
+ system.defaults.dock.autohide = mkOption {
+ type = types.nullOr types.bool;
+ default = null;
+ };
+
+ };
+}
diff --git a/modules/system/defaults/finder.nix b/modules/system/defaults/finder.nix
new file mode 100644
index 0000000..aa836ab
--- /dev/null
+++ b/modules/system/defaults/finder.nix
@@ -0,0 +1,14 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+ options = {
+
+ system.defaults.finder.AppleShowAllExtensions = mkOption {
+ type = types.nullOr types.bool;
+ default = null;
+ };
+
+ };
+}
diff --git a/modules/system/defaults/trackpad.nix b/modules/system/defaults/trackpad.nix
new file mode 100644
index 0000000..6736ce1
--- /dev/null
+++ b/modules/system/defaults/trackpad.nix
@@ -0,0 +1,14 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+ options = {
+
+ system.defaults.trackpad.Clicking = mkOption {
+ type = types.nullOr types.bool;
+ default = null;
+ };
+
+ };
+}