1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

add time.timeZone option

This commit is contained in:
Daiderd Jordan 2016-12-16 12:20:28 +01:00
parent d97cc2d59d
commit 345941b4d8
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 48 additions and 0 deletions

View file

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

View file

@ -61,6 +61,7 @@ in
${cfg.activationScripts.etc.text}
${cfg.activationScripts.launchd.text}
${cfg.activationScripts.time.text}
exit $_status
'';

46
modules/time/default.nix Normal file
View file

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