From e90adfaf87c68785af0f66becb0d5c8fc59b9e2f Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Fri, 11 Aug 2023 11:52:50 -0700 Subject: [PATCH] Add module with tatoeba service definition --- flake.nix | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/flake.nix b/flake.nix index 8e3f441..982937d 100644 --- a/flake.nix +++ b/flake.nix @@ -50,5 +50,37 @@ }; }); }; + nixosModules.default = { config, ... }: let + lib = nixpkgs.lib; + in { + options.services.tatoeba = { + enable = lib.mkEnableOption (lib.mdDoc "tatoeba service"); + package = lib.mkOption { + type = lib.types.package; + default = self.packages.${system}.tatoeba; + defaultText = "pkgs.tatoeba"; + description = lib.mdDoc '' + The tatoeba package that should be used. + ''; + }; + }; + config = { + systemd.services.tatoeba = let + cfg = config.services.tatoeba; + pkg = self.packages.${system}.tatoeba; + in lib.mkIf cfg.enable { + description = pkg.meta.description; + after = [ "network.target" ]; + wantedBy = [ "network.target" ]; + serviceConfig = { + ExecStart = '' + ${cfg.package}/bin/tatoeba + ''; + Restart = "always"; + DynamicUser = true; + }; + }; + }; + }; }; }