mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-13 20:30:02 +00:00
move system.defaults to separate files
This commit is contained in:
parent
6af52615ed
commit
a48cc8ac5f
8 changed files with 129 additions and 32 deletions
|
@ -8,7 +8,12 @@ let
|
|||
[ config
|
||||
./modules/system
|
||||
./modules/system/activation-scripts.nix
|
||||
./modules/system/defaults
|
||||
./modules/system/defaults-write.nix
|
||||
./modules/system/defaults/NSGlobalDomain.nix
|
||||
./modules/system/defaults/LaunchServices.nix
|
||||
./modules/system/defaults/dock.nix
|
||||
./modules/system/defaults/finder.nix
|
||||
./modules/system/defaults/trackpad.nix
|
||||
./modules/system/etc.nix
|
||||
./modules/system/launchd.nix
|
||||
./modules/nix/nix-darwin.nix
|
||||
|
|
48
modules/system/defaults-write.nix
Normal file
48
modules/system/defaults-write.nix
Normal file
|
@ -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}
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
14
modules/system/defaults/LaunchServices.nix
Normal file
14
modules/system/defaults/LaunchServices.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
|
||||
system.defaults.LaunchServices.LSQuarantine = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
19
modules/system/defaults/NSGlobalDomain.nix
Normal file
19
modules/system/defaults/NSGlobalDomain.nix
Normal file
|
@ -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;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
|
@ -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 = {
|
||||
|
|
14
modules/system/defaults/dock.nix
Normal file
14
modules/system/defaults/dock.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
|
||||
system.defaults.dock.autohide = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
14
modules/system/defaults/finder.nix
Normal file
14
modules/system/defaults/finder.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
|
||||
system.defaults.finder.AppleShowAllExtensions = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
14
modules/system/defaults/trackpad.nix
Normal file
14
modules/system/defaults/trackpad.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
|
||||
system.defaults.trackpad.Clicking = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue