mirror of
https://codeberg.org/icewind/tasmota-backup.git
synced 2026-06-03 06:14:12 +02:00
fmt
This commit is contained in:
parent
191e3868f6
commit
22e415ba6a
5 changed files with 46 additions and 44 deletions
|
|
@ -28,6 +28,8 @@ password = "device-password" # the device password is the MQTT password used by
|
||||||
# password-file = "/path/to/device-password"
|
# 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.
|
||||||
|
|
|
||||||
23
flake.nix
23
flake.nix
|
|
@ -10,22 +10,23 @@
|
||||||
inputs.flakelight.follows = "flakelight";
|
inputs.flakelight.follows = "flakelight";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = { mill-scale, ... }: mill-scale ./. {
|
outputs = {mill-scale, ...}:
|
||||||
withOverlays = import ./overlay.nix;
|
mill-scale ./. {
|
||||||
|
withOverlays = import ./overlay.nix;
|
||||||
|
|
||||||
nixosModules = { outputs, ... }: {
|
nixosModules = {outputs, ...}: {
|
||||||
default =
|
default = {
|
||||||
{ pkgs
|
pkgs,
|
||||||
, config
|
config,
|
||||||
, lib
|
lib,
|
||||||
, ...
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [ ./module.nix ];
|
imports = [./module.nix];
|
||||||
config = lib.mkIf config.services.tasmota-backup.enable {
|
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;
|
services.tasmota-backup.package = lib.mkDefault pkgs.tasmota-backup;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
module.nix
24
module.nix
|
|
@ -1,10 +1,11 @@
|
||||||
{ config
|
{
|
||||||
, lib
|
config,
|
||||||
, pkgs
|
lib,
|
||||||
, ...
|
pkgs,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
format = pkgs.formats.toml { };
|
format = pkgs.formats.toml {};
|
||||||
configFile = format.generate "tasmota-backup.toml" {
|
configFile = format.generate "tasmota-backup.toml" {
|
||||||
output.target = cfg.outputPath;
|
output.target = cfg.outputPath;
|
||||||
mqtt = {
|
mqtt = {
|
||||||
|
|
@ -14,8 +15,7 @@ with lib; let
|
||||||
device."password-file" = "$CREDENTIALS_DIRECTORY/device_password";
|
device."password-file" = "$CREDENTIALS_DIRECTORY/device_password";
|
||||||
};
|
};
|
||||||
cfg = config.services.tasmota-backup;
|
cfg = config.services.tasmota-backup;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.services.tasmota-backup = {
|
options.services.tasmota-backup = {
|
||||||
enable = mkEnableOption "Log archiver";
|
enable = mkEnableOption "Log archiver";
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
users.groups.tasmota-backup = { };
|
users.groups.tasmota-backup = {};
|
||||||
users.users.tasmota-backup = {
|
users.users.tasmota-backup = {
|
||||||
group = config.users.groups.tasmota-backup.name;
|
group = config.users.groups.tasmota-backup.name;
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
|
|
@ -83,7 +83,7 @@ in
|
||||||
"mqtt_password:${cfg.mqtt.passwordFile}"
|
"mqtt_password:${cfg.mqtt.passwordFile}"
|
||||||
"device_password:${cfg.devicePasswordFile}"
|
"device_password:${cfg.devicePasswordFile}"
|
||||||
];
|
];
|
||||||
BindPaths = [ cfg.outputPath ];
|
BindPaths = [cfg.outputPath];
|
||||||
User = "tasmota-backup";
|
User = "tasmota-backup";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
|
|
@ -102,10 +102,10 @@ in
|
||||||
ProtectHostname = true;
|
ProtectHostname = true;
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
ProtectKernelTunables = true;
|
ProtectKernelTunables = true;
|
||||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
RestrictAddressFamilies = ["AF_INET" "AF_INET6"];
|
||||||
RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
ProtectProc = "noaccess";
|
ProtectProc = "noaccess";
|
||||||
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
|
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
||||||
IPAddressDeny = mkDefault "multicast";
|
IPAddressDeny = mkDefault "multicast";
|
||||||
PrivateUsers = true;
|
PrivateUsers = true;
|
||||||
ProcSubset = "pid";
|
ProcSubset = "pid";
|
||||||
|
|
@ -130,7 +130,7 @@ in
|
||||||
inherit (config.systemd.services."tasmota-backup") description;
|
inherit (config.systemd.services."tasmota-backup") description;
|
||||||
|
|
||||||
enable = true;
|
enable = true;
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = ["multi-user.target"];
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnCalendar = cfg.interval;
|
OnCalendar = cfg.interval;
|
||||||
RandomizedDelaySec = "15m";
|
RandomizedDelaySec = "15m";
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
final: prev: {
|
final: prev: {
|
||||||
tasmota-backup = final.callPackage ./package.nix { };
|
tasmota-backup = final.callPackage ./package.nix {};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
package.nix
35
package.nix
|
|
@ -1,23 +1,22 @@
|
||||||
{ stdenv
|
{
|
||||||
, rustPlatform
|
stdenv,
|
||||||
, libsodium
|
rustPlatform,
|
||||||
, pkg-config
|
libsodium,
|
||||||
, lib
|
pkg-config,
|
||||||
,
|
lib,
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
inherit (lib.sources) sourceByRegex;
|
inherit (lib.sources) sourceByRegex;
|
||||||
src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
|
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "tasmota-backup";
|
pname = "tasmota-backup";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue