first commit

This commit is contained in:
Stuce 2025-11-16 10:08:35 +01:00
commit 3a2241e434
4 changed files with 247 additions and 0 deletions

76
flake.nix Normal file
View file

@ -0,0 +1,76 @@
{
description =
"A flake for calDAVtoCSV, a middleman program between my Radicale server and my ESP32";
inputs = {
nixpkgs.url =
"github:nixos/nixpkgs/nixos-unstable"; # Specify the version or channel as needed
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
packages.default = pkgs.python3.pkgs.buildPythonApplication rec {
pname = "calDAVtoCSV";
version = "0.1.0";
pyproject = true;
src = ./.;
build-system = with pkgs.python3.pkgs; [ setuptools ];
dependencies = with pkgs.python3.pkgs; [ caldav flask gunicorn ];
meta = {
description =
"middleman program between my radicale server and my esp32";
license = pkgs.lib.licenses.mit;
maintainers = with pkgs.lib.maintainers; [ stuce-bot ];
};
};
nixosModules.caldavToCsv = { config, lib, ... }:
let cfg = config.services.caldavToCsv;
in {
options.NixosModule = {
enable = lib.mkEnableOption "Enable calDAVtoCSV service";
port = lib.mkOption {
type = lib.types.int;
default = 8000;
description = "Port on which calDAVtoCSV will listen";
};
url = lib.mkOption {
type = lib.types.str;
description = "url of the calendar";
};
calendarUsername = lib.mkOption {
type = lib.types.str;
description = "username of the calendar account";
};
calendarName = lib.mkOption {
type = lib.types.str;
description =
"name of the calendar we will fetch the todo items from";
};
calendarPasswordFile = lib.mkOption {
type = lib.types.str;
description =
"file where we need to look for password to connect, needs to be readeable by the service user";
};
};
config = lib.mkIf config.myModule.enable {
systemd.services.calDAVtoCSV = {
description = "calDAV to CSV Service";
after = [ "network.target" ];
serviceConfig = {
ExecStart =
"${pkgs.python3.pkgs.gunicorn}/bin/gunicorn -w 1 -b 0.0.0.0:${cfg.port} main:app";
Restart = "on-failure";
};
wantedBy = [ "multi-user.target" ];
};
};
};
});
}