mirror of
https://codeberg.org/demostf/backup.git
synced 2026-06-03 09:54:18 +02:00
flake reorg
This commit is contained in:
parent
a603ec8cfa
commit
23fc8d2509
8 changed files with 123 additions and 105 deletions
96
nix/module.nix
Normal file
96
nix/module.nix
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.demostf-backup;
|
||||
in {
|
||||
options.services.demostf-backup = {
|
||||
enable = mkEnableOption "Enables the demos backup service";
|
||||
|
||||
target = mkOption {
|
||||
type = types.str;
|
||||
description = "target directory";
|
||||
};
|
||||
api = mkOption {
|
||||
type = types.str;
|
||||
default = "https://api.demos.tf";
|
||||
description = "demos.tf api url";
|
||||
};
|
||||
stateFile = mkOption {
|
||||
type = types.str;
|
||||
description = "state file path";
|
||||
};
|
||||
logLevel = mkOption {
|
||||
type = types.str;
|
||||
default = "INFO";
|
||||
description = "log level";
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
description = "user that owns the demos";
|
||||
};
|
||||
interval = mkOption {
|
||||
type = types.str;
|
||||
default = "*:0/10";
|
||||
description = "Interval to run the service";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
defaultText = literalExpression "pkgs.demostf-backup";
|
||||
description = "package to use";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.demostf-backup = {
|
||||
description = "Backup demos for demos.tf";
|
||||
|
||||
environment = {
|
||||
STORAGE_ROOT = cfg.target;
|
||||
SOURCE = cfg.api;
|
||||
STATE_FILE = cfg.stateFile;
|
||||
RUST_LOG = cfg.logLevel;
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/demostf-backup";
|
||||
ReadWritePaths = [cfg.target cfg.stateFile];
|
||||
Restart = "on-failure";
|
||||
User = cfg.user;
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "strict";
|
||||
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";
|
||||
RestrictRealtime = true;
|
||||
ProtectProc = "noaccess";
|
||||
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
||||
IPAddressDeny = "localhost link-local multicast";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.timers.demostf-backup = {
|
||||
enable = true;
|
||||
description = "Backup demos for demos.tf";
|
||||
wantedBy = ["multi-user.target"];
|
||||
timerConfig = {
|
||||
OnCalendar = "*:0/10";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
3
nix/overlay.nix
Normal file
3
nix/overlay.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
demostf-backup = final.callPackage ./package.nix {};
|
||||
}
|
||||
31
nix/package.nix
Normal file
31
nix/package.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
rustPlatform,
|
||||
lib,
|
||||
openssl,
|
||||
pkg-config,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
inherit (builtins) fromTOML readFile;
|
||||
src = sourceByRegex ../. ["Cargo.*" "(src)(/.*)?"];
|
||||
cargoPackage = (fromTOML (readFile ../Cargo.toml)).package;
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = cargoPackage.name;
|
||||
inherit (cargoPackage) version;
|
||||
|
||||
inherit src;
|
||||
|
||||
buildInputs = [
|
||||
openssl
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
];
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
|
||||
meta.mainProgram = "demostf-backup";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue