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; + }; + }; + }; + }; }; }