mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 03:30:45 +00:00
timezone.nix -> locale.nix
Also includes geolocation information abstracted from redshift.nix
This commit is contained in:
parent
c5592fabba
commit
c4de0bf492
|
@ -9,6 +9,8 @@ let
|
|||
timezone = types.nullOr (types.addCheck types.str nospace)
|
||||
// { description = "null or string without spaces"; };
|
||||
|
||||
lcfg = config.location;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -37,12 +39,45 @@ in
|
|||
};
|
||||
|
||||
};
|
||||
|
||||
location = {
|
||||
|
||||
latitude = mkOption {
|
||||
type = types.float;
|
||||
description = ''
|
||||
Your current latitude, between
|
||||
<literal>-90.0</literal> and <literal>90.0</literal>. Must be provided
|
||||
along with longitude.
|
||||
'';
|
||||
};
|
||||
|
||||
longitude = mkOption {
|
||||
type = types.float;
|
||||
description = ''
|
||||
Your current longitude, between
|
||||
between <literal>-180.0</literal> and <literal>180.0</literal>. Must be
|
||||
provided along with latitude.
|
||||
'';
|
||||
};
|
||||
|
||||
provider = mkOption {
|
||||
type = types.enum [ "manual" "geoclue2" ];
|
||||
default = "manual";
|
||||
description = ''
|
||||
The location provider to use for determining your location. If set to
|
||||
<literal>manual</literal> you must also provide latitude/longitude.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
environment.sessionVariables.TZDIR = "/etc/zoneinfo";
|
||||
|
||||
services.geoclue2.enable = mkIf (lcfg.provider == "geoclue2") true;
|
||||
|
||||
# This way services are restarted when tzdata changes.
|
||||
systemd.globalEnvironment.TZDIR = tzdir;
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
./config/iproute2.nix
|
||||
./config/krb5/default.nix
|
||||
./config/ldap.nix
|
||||
./config/locale.nix
|
||||
./config/malloc.nix
|
||||
./config/networking.nix
|
||||
./config/no-x-libs.nix
|
||||
|
@ -33,7 +34,6 @@
|
|||
./config/system-environment.nix
|
||||
./config/system-path.nix
|
||||
./config/terminfo.nix
|
||||
./config/timezone.nix
|
||||
./config/unix-odbc-drivers.nix
|
||||
./config/users-groups.nix
|
||||
./config/vpnc.nix
|
||||
|
|
|
@ -257,6 +257,20 @@ with lib;
|
|||
(mkRenamedOptionModule [ "networking" "extraResolvconfConf" ] [ "networking" "resolvconf" "extraConfig" ])
|
||||
(mkRenamedOptionModule [ "networking" "resolvconfOptions" ] [ "networking" "resolvconf" "extraOptions" ])
|
||||
|
||||
# Redshift
|
||||
(mkChangedOptionModule [ "services" "redshift" "latitude" ] [ "location" "latitude" ]
|
||||
(config:
|
||||
let value = getAttrFromPath [ "services" "redshift" "latitude" ] config;
|
||||
in if value == null then
|
||||
throw "services.redshift.latitude is set to null, you can remove this"
|
||||
else builtins.fromJSON value))
|
||||
(mkChangedOptionModule [ "services" "redshift" "longitude" ] [ "location" "longitude" ]
|
||||
(config:
|
||||
let value = getAttrFromPath [ "services" "redshift" "longitude" ] config;
|
||||
in if value == null then
|
||||
throw "services.redshift.longitude is set to null, you can remove this"
|
||||
else builtins.fromJSON value))
|
||||
|
||||
] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
|
||||
"jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
|
||||
"snmpExporter" "unifiExporter" "varnishExporter" ]
|
||||
|
|
|
@ -5,6 +5,7 @@ with lib;
|
|||
let
|
||||
|
||||
cfg = config.services.redshift;
|
||||
lcfg = config.location;
|
||||
|
||||
in {
|
||||
|
||||
|
@ -18,35 +19,6 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
latitude = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Your current latitude, between
|
||||
<literal>-90.0</literal> and <literal>90.0</literal>. Must be provided
|
||||
along with longitude.
|
||||
'';
|
||||
};
|
||||
|
||||
longitude = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Your current longitude, between
|
||||
between <literal>-180.0</literal> and <literal>180.0</literal>. Must be
|
||||
provided along with latitude.
|
||||
'';
|
||||
};
|
||||
|
||||
provider = mkOption {
|
||||
type = types.enum [ "manual" "geoclue2" ];
|
||||
default = "manual";
|
||||
description = ''
|
||||
The location provider to use for determining your location. If set to
|
||||
<literal>manual</literal> you must also provide latitude/longitude.
|
||||
'';
|
||||
};
|
||||
|
||||
temperature = {
|
||||
day = mkOption {
|
||||
type = types.int;
|
||||
|
@ -106,33 +78,19 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion =
|
||||
if cfg.provider == "manual"
|
||||
then (cfg.latitude != null && cfg.longitude != null)
|
||||
else (cfg.latitude == null && cfg.longitude == null);
|
||||
message = "Latitude and longitude must be provided together, and with provider set to null.";
|
||||
}
|
||||
];
|
||||
|
||||
# needed so that .desktop files are installed, which geoclue cares about
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
services.geoclue2 = mkIf (cfg.provider == "geoclue2") {
|
||||
enable = true;
|
||||
appConfig."redshift" = {
|
||||
isAllowed = true;
|
||||
isSystem = true;
|
||||
};
|
||||
services.geoclue2.appConfig."redshift" = {
|
||||
isAllowed = true;
|
||||
isSystem = true;
|
||||
};
|
||||
|
||||
systemd.user.services.redshift =
|
||||
let
|
||||
providerString =
|
||||
if cfg.provider == "manual"
|
||||
then "${cfg.latitude}:${cfg.longitude}"
|
||||
else cfg.provider;
|
||||
providerString = if lcfg.provider == "manual"
|
||||
then "${toString lcfg.latitude}:${toString lcfg.longitude}"
|
||||
else lcfg.provider;
|
||||
in
|
||||
{
|
||||
description = "Redshift colour temperature adjuster";
|
||||
|
|
Loading…
Reference in a new issue