diff --git a/Cargo.lock b/Cargo.lock index 92f3eff..a639e60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -332,6 +332,23 @@ dependencies = [ "phf_codegen", ] +[[package]] +name = "chrono_track" +version = "0.1.0" +dependencies = [ + "chrono", + "chrono-tz", + "clap", + "csv", + "lettre", + "log", + "reqwest", + "serde", + "serde_json", + "simplelog", + "toml", +] + [[package]] name = "clap" version = "4.4.2" @@ -1555,23 +1572,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "time_tracker" -version = "0.1.0" -dependencies = [ - "chrono", - "chrono-tz", - "clap", - "csv", - "lettre", - "log", - "reqwest", - "serde", - "serde_json", - "simplelog", - "toml", -] - [[package]] name = "tinyvec" version = "1.6.0" diff --git a/chrono_track/Cargo.toml b/chrono_track/Cargo.toml index cac90bc..3b44e57 100644 --- a/chrono_track/Cargo.toml +++ b/chrono_track/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "time_tracker" +name = "chrono_track" version = "0.1.0" edition = "2021" diff --git a/flake.nix b/flake.nix index 04c2c84..867bb8d 100644 --- a/flake.nix +++ b/flake.nix @@ -62,25 +62,26 @@ rust-project TODO: write shell script for automatically updating `cargoHash` pname = "status_cloud"; version = "0.1.0"; buildAndTestSubdir = "status_cloud"; - cargoHash = "sha256-XIonh2SQ8EichcZvHErSydt0qtKGodXE0yKz4BsntA8="; - preBuild = '' - sed -i 's/Command::new("hddtemp")/Command::new("${nixpkgs.lib.escape [ "/" ] "${pkgs.hddtemp}"}")/g' status_cloud/src/main.rs + cargoHash = "sha256-mXcD/92WJLgN2efX/8EiV3rOqUiNOKGC4puS8DvGFOc="; + postFixup = '' + wrapProgram $out/bin/status_cloud \ + --prefix PATH : "${nixpkgs.lib.makeBinPath [ pkgs.hddtemp ]}" ''; meta = meta // { description = "Server status saved to a nextcloud note service."; }; }); - time_tracker = pkgs.rustPlatform.buildRustPackage (rustSettings // { - pname = "time_tracker"; + chrono_track = pkgs.rustPlatform.buildRustPackage (rustSettings // { + pname = "chrono_track"; version = "0.1.0"; - buildAndTestSubdir = "time_tracker"; - cargoHash = "sha256-5Wy2+ef2BriKmvNhllDVh/clAZGV7myDc281ygj05vI="; + buildAndTestSubdir = "chrono_track"; + cargoHash = "sha256-51j5eG2ZBJg2TjbvYSEvvmOM4hhPyNohN+LUmvck88k="; meta = meta // { description = "Using nextcloud notes to track time usage."; }; postFixup = '' - wrapProgram $out/bin/time_tracker \ + wrapProgram $out/bin/chrono_track \ --prefix PATH : "${nixpkgs.lib.makeBinPath [ pkgs.msmtp ]}" ''; }); @@ -138,14 +139,14 @@ rust-project TODO: write shell script for automatically updating `cargoHash` # Time Tracker - options.services.time_tracker = { - enable = lib.mkEnableOption (lib.mdDoc "time tracker service"); + options.services.chrono_track = { + enable = lib.mkEnableOption (lib.mdDoc "chrono track, time tracking service"); package = lib.mkOption { type = lib.types.package; - default = self.packages.${system}.time_tracker; - defaultText = "pkgs.time_tracker"; + default = self.packages.${system}.chrono_track; + defaultText = "pkgs.chrono_track"; description = lib.mdDoc '' - The time_tracker package that should be used + The chrono_track package that should be used ''; }; config_path = lib.mkOption { @@ -154,6 +155,12 @@ rust-project TODO: write shell script for automatically updating `cargoHash` The file path to the toml that contains user information secrets ''; }; + from_address = lib.mkOption { + type = lib.types.str; + description = lib.mdDoc '' + The from address for the emails. E.g. noreply@example.com + ''; + }; frequency = lib.mkOption { type = lib.types.int; description = lib.mdDoc '' @@ -162,25 +169,25 @@ rust-project TODO: write shell script for automatically updating `cargoHash` }; }; - config.systemd.services.time_tracker = let - cfg = config.services.time_tracker; - pkg = self.packages.${system}.time_tracker; + config.systemd.services.chrono_track = let + cfg = config.services.chrono_track; + pkg = self.packages.${system}.chrono_track; in lib.mkIf cfg.enable { - description = "Nextcloud Time Tracker"; + description = "Chrono Track"; serviceConfig = { Type = "oneshot"; ExecStart = '' - ${cfg.package}/bin/time_tracker --config-file ${builtins.toString cfg.config_path} + ${cfg.package}/bin/chrono_track --config-file ${builtins.toString cfg.config_path} --from_addr ${cfg.from_address} ''; }; }; - config.systemd.timers.time_tracker = let - cfg = config.services.time_tracker; - pkg = self.packages.${system}.time_tracker; + config.systemd.timers.chrono_track = let + cfg = config.services.chrono_track; + pkg = self.packages.${system}.chrono_track; in lib.mkIf cfg.enable { wantedBy = [ "timers.target" ]; - partOf = [ "time_tracker.service" ]; + partOf = [ "chrono_track.service" ]; timerConfig.OnCalendar = [ "*:0/${builtins.toString cfg.frequency}" ]; };