move services
This commit is contained in:
parent
128005e354
commit
feb53bc5fc
23 changed files with 28 additions and 28 deletions
68
modules/nixos/services/system-logger/default.nix
Normal file
68
modules/nixos/services/system-logger/default.nix
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
system-logger = pkgs.writeShellApplication {
|
||||
name = "system-logger";
|
||||
runtimeInputs = with pkgs; [
|
||||
curl
|
||||
jq
|
||||
zip
|
||||
gawk
|
||||
systemd
|
||||
];
|
||||
text = builtins.readFile ./system-logger.sh;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.services.system-logger = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable System Logger Service";
|
||||
default = false;
|
||||
};
|
||||
|
||||
logDirectory = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "/var/lib/system-logger";
|
||||
description = "Directory to store log archives";
|
||||
};
|
||||
|
||||
maxSizeMB = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 1;
|
||||
description = "Maximum size of daily log archive in megabytes";
|
||||
};
|
||||
|
||||
retentionDays = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 30;
|
||||
description = "Number of days to retain log archives";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.services.system-logger.enable {
|
||||
systemd.timers.system-logger = {
|
||||
description = "System Logger Timer";
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.system-logger = {
|
||||
description = "System Logger Service";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${lib.getExe system-logger}";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 60;
|
||||
User = "root";
|
||||
Group = "root";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue