mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
time: Add timeZone option
This commit is contained in:
parent
7e6946c627
commit
9323f2f573
2 changed files with 58 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
./environment/session-init.nix
|
./environment/session-init.nix
|
||||||
./home-manager.nix
|
./home-manager.nix
|
||||||
./nixpkgs.nix
|
./nixpkgs.nix
|
||||||
|
./time.nix
|
||||||
./user.nix
|
./user.nix
|
||||||
./version.nix
|
./version.nix
|
||||||
<nixpkgs/nixos/modules/misc/assertions.nix>
|
<nixpkgs/nixos/modules/misc/assertions.nix>
|
||||||
|
|
|
||||||
57
modules/time.nix
Normal file
57
modules/time.nix
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
|
# Inspired by
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/locale.nix
|
||||||
|
# (Copyright (c) 2003-2019 Eelco Dolstra and the Nixpkgs/NixOS contributors,
|
||||||
|
# licensed under MIT License as well)
|
||||||
|
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.time;
|
||||||
|
|
||||||
|
tzdir = "${pkgs.tzdata}/share/zoneinfo";
|
||||||
|
nospace = str: filter (c: c == " ") (stringToCharacters str) == [];
|
||||||
|
timezoneType = types.nullOr (types.addCheck types.str nospace)
|
||||||
|
// { description = "null or string without spaces"; };
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
time.timeZone = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = timezoneType;
|
||||||
|
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"/>
|
||||||
|
for a comprehensive list of possible values for this setting.
|
||||||
|
If null, the timezone will default to UTC.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
config = {
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
etc =
|
||||||
|
{ zoneinfo.source = tzdir; }
|
||||||
|
// optionalAttrs (config.time.timeZone != null) {
|
||||||
|
localtime.source = "/etc/zoneinfo/${config.time.timeZone}";
|
||||||
|
};
|
||||||
|
|
||||||
|
sessionVariables.TZDIR = "/etc/zoneinfo";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue