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
cfg = config.services.chrony;
chronyPkg = cfg.package;
stateDir = cfg.directory;
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 {
default = config.networking.timeServers;
description = ''
@ -109,7 +119,7 @@ in
config = mkIf cfg.enable {
meta.maintainers = with lib.maintainers; [ thoughtpolice ];
environment.systemPackages = [ pkgs.chrony ];
environment.systemPackages = [ chronyPkg ];
users.groups.chrony.gid = config.ids.gids.chrony;
@ -139,12 +149,12 @@ in
after = [ "network.target" ];
conflicts = [ "ntpd.service" "systemd-timesyncd.service" ];
path = [ pkgs.chrony ];
path = [ chronyPkg ];
unitConfig.ConditionCapability = "CAP_SYS_TIME";
serviceConfig =
{ Type = "simple";
ExecStart = "${pkgs.chrony}/bin/chronyd ${chronyFlags}";
ExecStart = "${chronyPkg}/bin/chronyd ${chronyFlags}";
ProtectHome = "yes";
ProtectSystem = "full";