nixos/chrony: add option to change package

This commit is contained in:
Ctem 2021-01-06 19:42:28 +09:00
parent 2aec205bd2
commit 54778551d6
No known key found for this signature in database
GPG Key ID: 7F6702F5FC77041B

View File

@ -4,6 +4,7 @@ with lib;
let let
cfg = config.services.chrony; cfg = config.services.chrony;
chronyPkg = cfg.package;
stateDir = cfg.directory; stateDir = cfg.directory;
driftFile = "${stateDir}/chrony.drift"; driftFile = "${stateDir}/chrony.drift";
@ -40,6 +41,15 @@ in
''; '';
}; };
package = mkOption {
type = types.package;
default = pkgs.chrony;
defaultText = "pkgs.chrony";
description = ''
Which chrony package to use.
'';
};
servers = mkOption { servers = mkOption {
default = config.networking.timeServers; default = config.networking.timeServers;
description = '' description = ''
@ -109,7 +119,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
meta.maintainers = with lib.maintainers; [ thoughtpolice ]; meta.maintainers = with lib.maintainers; [ thoughtpolice ];
environment.systemPackages = [ pkgs.chrony ]; environment.systemPackages = [ chronyPkg ];
users.groups.chrony.gid = config.ids.gids.chrony; users.groups.chrony.gid = config.ids.gids.chrony;
@ -139,12 +149,12 @@ in
after = [ "network.target" ]; after = [ "network.target" ];
conflicts = [ "ntpd.service" "systemd-timesyncd.service" ]; conflicts = [ "ntpd.service" "systemd-timesyncd.service" ];
path = [ pkgs.chrony ]; path = [ chronyPkg ];
unitConfig.ConditionCapability = "CAP_SYS_TIME"; unitConfig.ConditionCapability = "CAP_SYS_TIME";
serviceConfig = serviceConfig =
{ Type = "simple"; { Type = "simple";
ExecStart = "${pkgs.chrony}/bin/chronyd ${chronyFlags}"; ExecStart = "${chronyPkg}/bin/chronyd ${chronyFlags}";
ProtectHome = "yes"; ProtectHome = "yes";
ProtectSystem = "full"; ProtectSystem = "full";