1
0
Fork 0
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:
Daiderd Jordan 2016-12-14 13:05:23 +01:00
parent 6af52615ed
commit a48cc8ac5f
No known key found for this signature in database
GPG key ID: D02435D05B810C96
8 changed files with 129 additions and 32 deletions

View file

@ -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

View 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}
'';
};
}

View file

@ -0,0 +1,14 @@
{ config, lib, ... }:
with lib;
{
options = {
system.defaults.LaunchServices.LSQuarantine = mkOption {
type = types.nullOr types.bool;
default = null;
};
};
}

View 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;
};
};
}

View file

@ -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 = {

View file

@ -0,0 +1,14 @@
{ config, lib, ... }:
with lib;
{
options = {
system.defaults.dock.autohide = mkOption {
type = types.nullOr types.bool;
default = null;
};
};
}

View file

@ -0,0 +1,14 @@
{ config, lib, ... }:
with lib;
{
options = {
system.defaults.finder.AppleShowAllExtensions = mkOption {
type = types.nullOr types.bool;
default = null;
};
};
}

View file

@ -0,0 +1,14 @@
{ config, lib, ... }:
with lib;
{
options = {
system.defaults.trackpad.Clicking = mkOption {
type = types.nullOr types.bool;
default = null;
};
};
}