From 138bc695901ca9431b03eb5aa8b018da8b85ef6e Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 12 Aug 2023 13:43:36 -0700 Subject: [PATCH] Add module with images service definition --- flake.nix | 64 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 15 deletions(-) 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; }; }; };