1
1
Fork 0

Factor out time zone and NTP

This commit is contained in:
Tim Van Baak 2023-08-02 02:17:10 +00:00
parent 4e8a2bb7e4
commit 7feec36673
2 changed files with 24 additions and 16 deletions

View File

@ -17,14 +17,6 @@
# Enable networking # Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "UTC";
services.ntp = {
enable = true;
servers = [ "time.nist.gov" ];
};
# Select internationalisation properties. # Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";

View File

@ -1,18 +1,34 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
inherit (lib) mkOption types; inherit (lib) mkIf mkMerge mkOption types;
cfg = config.beatific; cfg = config.beatific;
in { in {
options = { options = {
beatific.hostName = mkOption { beatific = {
type = types.str; hostName = mkOption {
description = "Hostname"; type = types.str;
description = "Hostname";
};
defaults = {
time = mkOption {
type = types.bool;
description = "Default time zone and NTP";
default = true;
};
};
}; };
}; };
config = let config = mkMerge [
in { {
networking.hostName = cfg.hostName; networking.hostName = cfg.hostName;
}; }
(mkIf cfg.defaults.time {
time.timeZone = "UTC";
services.ntp.enable = true;
services.ntp.servers = [ "time.nist.gov" ];
})
];
} }