diff --git a/flake.nix b/flake.nix index 6c84287..d5ad55c 100644 --- a/flake.nix +++ b/flake.nix @@ -58,6 +58,7 @@ nixosModules.default = { config, ... }: let lib = nixpkgs.lib; in { + # tatoeba options.services.tatoeba = { enable = lib.mkEnableOption (lib.mdDoc "tatoeba service"); package = lib.mkOption { @@ -76,21 +77,54 @@ ''; }; }; - 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 --port ${builtins.toString cfg.port} - ''; - Restart = "always"; - DynamicUser = true; - }; + 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 --port ${builtins.toString cfg.port} + ''; + Restart = "always"; + DynamicUser = true; + }; + }; + + # images + options.services.images = { + enable = lib.mkEnableOption (lib.mdDoc "images service"); + package = lib.mkOption { + type = lib.types.package; + default = self.packages.${system}.images; + defaultText = "pkgs.images"; + description = lib.mdDoc '' + The images package that should be used. + ''; + }; + port = lib.mkOption { + type = lib.types.port; + default = 3002; + description = lib.mdDoc '' + The port at which to run. + ''; + }; + }; + config.systemd.services.images = let + cfg = config.services.images; + pkg = self.packages.${system}.images; + in lib.mkIf cfg.enable { + description = pkg.meta.description; + after = [ "network.target" ]; + wantedBy = [ "network.target" ]; + serviceConfig = { + ExecStart = '' + ${cfg.package}/bin/images --port ${builtins.toString cfg.port} + ''; + Restart = "always"; + DynamicUser = true; }; }; };