mirror of
https://codeberg.org/icewind/log-archiver.git
synced 2026-06-03 09:34:09 +02:00
flake reorg
This commit is contained in:
parent
a650f7f970
commit
db5cef6fb7
10 changed files with 109 additions and 85 deletions
80
nix/module.nix
Normal file
80
nix/module.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.log-archiver;
|
||||
in {
|
||||
options.services.log-archiver = {
|
||||
enable = mkEnableOption "Log archiver";
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
description = "user to save logs as";
|
||||
};
|
||||
|
||||
databaseUrlFile = mkOption {
|
||||
type = types.str;
|
||||
description = "file containing DATABASE_URL variable";
|
||||
};
|
||||
|
||||
baseUrl = mkOption {
|
||||
type = types.str;
|
||||
default = "https://logs.tf";
|
||||
description = "logs.tf base url";
|
||||
};
|
||||
|
||||
target = mkOption {
|
||||
type = types.str;
|
||||
description = "path to store logs to";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
description = "package to use";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services."log-archiver" = {
|
||||
wantedBy = ["multi-user.target"];
|
||||
environment = {
|
||||
API_BASE = cfg.baseUrl;
|
||||
LOG_TARGET = cfg.target;
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
EnvironmentFile = cfg.databaseUrlFile;
|
||||
ExecStart = "${cfg.package}/bin/log-archiver";
|
||||
Restart = "on-failure";
|
||||
User = cfg.user;
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "strict";
|
||||
ReadWritePaths = cfg.target;
|
||||
ProtectHome = true;
|
||||
NoNewPrivileges = true;
|
||||
PrivateDevices = true;
|
||||
ProtectClock = true;
|
||||
CapabilityBoundingSet = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectControlGroups = true;
|
||||
SystemCallArchitectures = "native";
|
||||
ProtectKernelModules = true;
|
||||
RestrictNamespaces = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
ProtectHostname = true;
|
||||
LockPersonality = true;
|
||||
ProtectKernelTunables = true;
|
||||
RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX";
|
||||
RestrictRealtime = true;
|
||||
ProtectProc = "noaccess";
|
||||
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
||||
IPAddressDeny = "multicast";
|
||||
PrivateUsers = true;
|
||||
ProcSubset = "pid";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
3
nix/overlay.nix
Normal file
3
nix/overlay.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
log-archiver = final.callPackage ./package.nix {};
|
||||
}
|
||||
19
nix/package.nix
Normal file
19
nix/package.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
rustPlatform,
|
||||
lib,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
src = sourceByRegex ../. ["Cargo.*" "(src|tests|.sqlx)(/.*)?"];
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "log-archiver";
|
||||
version = "0.1.0";
|
||||
|
||||
SQLX_OFFLINE = 1;
|
||||
|
||||
inherit src;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue