diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2016-12-16 12:20:28 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2016-12-16 12:20:28 +0100 |
| commit | 345941b4d8e982e3f0b29537875a337bacc993e6 (patch) | |
| tree | 52390460ffd9d423217e1407af6e80caae2aeefc | |
| parent | d97cc2d59da88eefa88ee8d3cdd1739b8a215a9b (diff) | |
add time.timeZone option
| -rw-r--r-- | default.nix | 1 | ||||
| -rw-r--r-- | modules/system/activation-scripts.nix | 1 | ||||
| -rw-r--r-- | modules/time/default.nix | 46 |
3 files changed, 48 insertions, 0 deletions
diff --git a/default.nix b/default.nix index f779266..44a1e17 100644 --- a/default.nix +++ b/default.nix @@ -16,6 +16,7 @@ let ./modules/system/defaults/trackpad.nix ./modules/system/etc.nix ./modules/system/launchd.nix + ./modules/time ./modules/nix ./modules/nix/nix-darwin.nix ./modules/nix/nixpkgs.nix diff --git a/modules/system/activation-scripts.nix b/modules/system/activation-scripts.nix index 6f22d45..c9f42bc 100644 --- a/modules/system/activation-scripts.nix +++ b/modules/system/activation-scripts.nix @@ -61,6 +61,7 @@ in ${cfg.activationScripts.etc.text} ${cfg.activationScripts.launchd.text} + ${cfg.activationScripts.time.text} exit $_status ''; diff --git a/modules/time/default.nix b/modules/time/default.nix new file mode 100644 index 0000000..5f7a5f5 --- /dev/null +++ b/modules/time/default.nix @@ -0,0 +1,46 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.time; + + timeZone = optionalString (cfg.timeZone != null) '' + if [ -z $(systemsetup -listtimezones | grep "^ ${cfg.timeZone}$") ]; then + echo "${cfg.timeZone} is not a valid timezone. The command 'listtimezones' will show a list of valid time zones." >&2 + false + fi + systemsetup -settimezone "${cfg.timeZone}" > /dev/null + ''; + +in + +{ + options = { + + time.timeZone = mkOption { + type = types.nullOr types.str; + default = null; + example = "America/New_York"; + description = '' + The time zone used when displaying times and dates. See <link + xlink:href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"/> + or run <command>sudo systemsetup -listtimezones</command> + for a comprehensive list of possible values for this setting. + ''; + }; + + }; + + config = { + + system.activationScripts.time.text = '' + # Set defaults + echo "configuring time..." >&2 + + ${timeZone} + ''; + + }; +} |
