feat: load configuration from TOML file for calendar settings
1 file changed, 52 insertions(+), 34 deletions(-)
changed files
M flake.nix → flake.nix
@@ -61,10 +61,12 @@ # Uv2nix can only work with what it has, and uv.lock is missing essential metadata to perform some builds. # This is an additional overlay implementing build fixups. # See: # - https://pyproject-nix.github.io/uv2nix/FAQ.html - pyprojectOverrides = _final: _prev: { - # Implement build fixups here. - # Note that uv2nix is _not_ using Nixpkgs buildPythonPackage. - # It's using https://pyproject-nix.github.io/pyproject.nix/build.html + pyprojectOverrides = final: prev: { + toml-dataclass = prev.toml-dataclass.overrideAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ final.resolveBuildSystem { + setuptools = [ ]; + }; + }); }; # Construct package set@@ -89,8 +91,10 @@ }; devShells = { default = pkgs.mkShell { - packages = with pkgs; [ + packages = (with pkgs; [ uv + ]) ++ [ + python ]; inputsFrom = [ self.packages.${pkgs.system}.default ]; env =@@ -119,6 +123,8 @@ cfg = config.services.mycal; pkg = cfg.venv; python = self.packages.${pkgs.system}.python; + settingsFormat = pkgs.formats.toml { }; + inherit (lib) mkEnableOption mkOption mkIf types; in {@@ -149,41 +155,56 @@ Mycal virtual environment package ''; }; - timezone = mkOption { - type = types.str; - default = "Europe/Berlin"; + settings = mkOption { + default = { }; description = '' - Default timezone for the calendar. + Additional settings for Mycal. ''; - }; - - name = mkOption { - type = types.str; - description = '' - Name of person for whom this calendar is created. - ''; - }; + type = types.submodule { + freeformType = settingsFormat.type; - calendar = mkOption { - default = { }; - type = types.submodule { options = { - file = mkOption { - type = with types; nullOr str; - default = null; - example = "/path/to/calendar/file"; + name = mkOption { + type = types.str; description = '' - Path to the calendar file. Preferred over URL. + Name of person for whom this calendar is created. ''; }; - url = mkOption { - type = with types; nullOr str; - default = null; - example = "https://example.com/calendar.ics"; + + timezone = mkOption { + type = types.str; + default = "Europe/Berlin"; description = '' - URL to the calendar file. + Default timezone for the calendar. ''; }; + + calendar = mkOption { + default = { }; + description = '' + Configuration for the calendar. Either a file or a URL must be provided. + ''; + type = types.submodule { + options = { + file = mkOption { + type = types.str; + default = ""; + example = "/path/to/calendar/file"; + description = '' + Path to the calendar file. Preferred over URL. + ''; + }; + url = mkOption { + type = types.str; + default = ""; + example = "https://example.com/calendar.ics"; + description = '' + URL to the calendar file. + ''; + }; + }; + }; + }; }; }; };@@ -194,11 +215,8 @@ systemd.services.mycal = { description = "Mycal Calendar Service"; environment = { - TZ = cfg.timezone; - NAME = cfg.name; - CALENDAR_FILE = cfg.calendar.file; - CALENDAR_URL = cfg.calendar.url; PYTHONPATH = "${python.pkgs.makePythonPath pkg.propagatedBuildInputs}:${pkg}/${python.sitePackages}"; + CONFIG_FILE = settingsFormat.generate "mycal-config.toml" cfg.settings; }; serviceConfig = {