mirror of
https://git.pvv.ntnu.no/Drift/pvv-nixos-config.git
synced 2025-06-05 21:25:22 +02:00
base/uptimed: init
This commit is contained in:
parent
9053dda57c
commit
7fb3e29d7b
@ -9,6 +9,7 @@
|
|||||||
./nix.nix
|
./nix.nix
|
||||||
|
|
||||||
./services/acme.nix
|
./services/acme.nix
|
||||||
|
./services/uptimed.nix
|
||||||
./services/auto-upgrade.nix
|
./services/auto-upgrade.nix
|
||||||
./services/dbus.nix
|
./services/dbus.nix
|
||||||
./services/fwupd.nix
|
./services/fwupd.nix
|
||||||
|
59
base/services/uptimed.nix
Normal file
59
base/services/uptimed.nix
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.services.uptimed;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.uptimed.settings = lib.mkOption {
|
||||||
|
description = "";
|
||||||
|
default = { };
|
||||||
|
type = lib.types.submodule {
|
||||||
|
freeformType = with lib.types; attrsOf (either str (listOf str));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
services.uptimed = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = let
|
||||||
|
stateDir = "/var/lib/uptimed";
|
||||||
|
in {
|
||||||
|
PIDFILE = "${stateDir}/pid";
|
||||||
|
SENDMAIL = lib.mkDefault "${pkgs.system-sendmail}/bin/sendmail -t";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.uptimed = lib.mkIf (cfg.enable) {
|
||||||
|
serviceConfig = let
|
||||||
|
uptimed = pkgs.uptimed.overrideAttrs (prev: {
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace Makefile.am \
|
||||||
|
--replace-fail '$(sysconfdir)/uptimed.conf' '/var/lib/uptimed/uptimed.conf'
|
||||||
|
substituteInPlace src/Makefile.am \
|
||||||
|
--replace-fail '$(sysconfdir)/uptimed.conf' '/var/lib/uptimed/uptimed.conf'
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
|
||||||
|
in {
|
||||||
|
Type = "notify";
|
||||||
|
|
||||||
|
ExecStart = lib.mkForce "${uptimed}/sbin/uptimed -f";
|
||||||
|
|
||||||
|
BindReadOnlyPaths = let
|
||||||
|
configFile = lib.pipe cfg.settings [
|
||||||
|
(lib.mapAttrsToList
|
||||||
|
(k: v:
|
||||||
|
if builtins.isList v
|
||||||
|
then lib.mapConcatStringsSep "\n" (v': "${k}=${v'}") v
|
||||||
|
else "${k}=${v}")
|
||||||
|
)
|
||||||
|
(lib.concatStringsSep "\n")
|
||||||
|
(pkgs.writeText "uptimed.conf")
|
||||||
|
];
|
||||||
|
in [
|
||||||
|
"${configFile}:/var/lib/uptimed/uptimed.conf"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user