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 /modules/time | |
| parent | d97cc2d59da88eefa88ee8d3cdd1739b8a215a9b (diff) | |
add time.timeZone option
Diffstat (limited to 'modules/time')
| -rw-r--r-- | modules/time/default.nix | 46 |
1 files changed, 46 insertions, 0 deletions
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} + ''; + + }; +} |
