This commit is contained in:
Robin Appelman 2025-06-02 22:12:22 +02:00
commit 22e415ba6a
5 changed files with 46 additions and 44 deletions

View file

@ -28,6 +28,8 @@ password = "device-password" # the device password is the MQTT password used by
# password-file = "/path/to/device-password"
```
A `.dmp` for every discovered device file will be written to the configured output directory.
A `.dmp` for every discovered device file will be written to the configured
output directory.
The output files should be stable as long as the device configuration isn't changed and the backup program will not overwrite existing unchanged files.
The output files should be stable as long as the device configuration isn't
changed and the backup program will not overwrite existing unchanged files.

View file

@ -10,19 +10,20 @@
inputs.flakelight.follows = "flakelight";
};
};
outputs = { mill-scale, ... }: mill-scale ./. {
outputs = {mill-scale, ...}:
mill-scale ./. {
withOverlays = import ./overlay.nix;
nixosModules = { outputs, ... }: {
default =
{ pkgs
, config
, lib
, ...
nixosModules = {outputs, ...}: {
default = {
pkgs,
config,
lib,
...
}: {
imports = [ ./module.nix ];
imports = [./module.nix];
config = lib.mkIf config.services.tasmota-backup.enable {
nixpkgs.overlays = [ (import ./overlay.nix) ];
nixpkgs.overlays = [(import ./overlay.nix)];
services.tasmota-backup.package = lib.mkDefault pkgs.tasmota-backup;
};
};

View file

@ -1,10 +1,11 @@
{ config
, lib
, pkgs
, ...
{
config,
lib,
pkgs,
...
}:
with lib; let
format = pkgs.formats.toml { };
format = pkgs.formats.toml {};
configFile = format.generate "tasmota-backup.toml" {
output.target = cfg.outputPath;
mqtt = {
@ -14,8 +15,7 @@ with lib; let
device."password-file" = "$CREDENTIALS_DIRECTORY/device_password";
};
cfg = config.services.tasmota-backup;
in
{
in {
options.services.tasmota-backup = {
enable = mkEnableOption "Log archiver";
@ -68,7 +68,7 @@ in
};
config = mkIf cfg.enable {
users.groups.tasmota-backup = { };
users.groups.tasmota-backup = {};
users.users.tasmota-backup = {
group = config.users.groups.tasmota-backup.name;
isSystemUser = true;
@ -83,7 +83,7 @@ in
"mqtt_password:${cfg.mqtt.passwordFile}"
"device_password:${cfg.devicePasswordFile}"
];
BindPaths = [ cfg.outputPath ];
BindPaths = [cfg.outputPath];
User = "tasmota-backup";
Restart = "on-failure";
PrivateTmp = true;
@ -102,10 +102,10 @@ in
ProtectHostname = true;
LockPersonality = true;
ProtectKernelTunables = true;
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
RestrictAddressFamilies = ["AF_INET" "AF_INET6"];
RestrictRealtime = true;
ProtectProc = "noaccess";
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
IPAddressDeny = mkDefault "multicast";
PrivateUsers = true;
ProcSubset = "pid";
@ -130,7 +130,7 @@ in
inherit (config.systemd.services."tasmota-backup") description;
enable = true;
wantedBy = [ "multi-user.target" ];
wantedBy = ["multi-user.target"];
timerConfig = {
OnCalendar = cfg.interval;
RandomizedDelaySec = "15m";

View file

@ -1,3 +1,3 @@
final: prev: {
tasmota-backup = final.callPackage ./package.nix { };
tasmota-backup = final.callPackage ./package.nix {};
}

View file

@ -1,15 +1,14 @@
{ stdenv
, rustPlatform
, libsodium
, pkg-config
, lib
,
}:
let
{
stdenv,
rustPlatform,
libsodium,
pkg-config,
lib,
}: let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
in
rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage rec {
pname = "tasmota-backup";
version = "0.1.0";
@ -20,4 +19,4 @@ rustPlatform.buildRustPackage rec {
cargoLock = {
lockFile = ./Cargo.lock;
};
}
}