initial commit

This commit is contained in:
TheGeneralist 2026-02-02 00:02:51 +01:00
commit ff8091fe98
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
6 changed files with 3895 additions and 0 deletions

71
flake.nix Normal file
View file

@ -0,0 +1,71 @@
{
description = "Read Later Telegram bot";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
let
packageFor =
system:
let
pkgs = import nixpkgs { inherit system; };
in
pkgs.rustPlatform.buildRustPackage {
pname = "readlater-bot";
version = "0.1.0";
src = self;
cargoLock.lockFile = ./Cargo.lock;
};
in
flake-utils.lib.eachDefaultSystem (system: {
packages.default = packageFor system;
})
// {
nixosModules.default =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.readlater-bot;
in
{
options.services.readlater-bot = {
enable = lib.mkEnableOption "Read Later Telegram bot";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.system}.default;
description = "Package providing the bot binary.";
};
configFile = lib.mkOption {
type = lib.types.path;
description = "Path to TOML config file.";
};
};
config = lib.mkIf cfg.enable {
systemd.services.readlater-bot = {
description = "Read Later Telegram bot";
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/readlater-bot --config ${cfg.configFile}";
Restart = "on-failure";
RestartSec = 5;
};
};
};
};
};
}