aboutsummaryrefslogtreecommitdiff
path: root/modules/home-manager/cook-cli/service.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/home-manager/cook-cli/service.nix')
-rw-r--r--modules/home-manager/cook-cli/service.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/modules/home-manager/cook-cli/service.nix b/modules/home-manager/cook-cli/service.nix
new file mode 100644
index 0000000..c4e8083
--- /dev/null
+++ b/modules/home-manager/cook-cli/service.nix
@@ -0,0 +1,56 @@
+{ config, pkgs, lib, ... }:
+with builtins // lib;
+let
+ cfg = config.services.cook-cli;
+ pcfg = config.programs.cook-cli;
+ args = escapeShellArgs ([
+ "--port"
+ (toString cfg.port)
+ ] ++ cfg.extraArgs ++ [
+ cfg.recipeRoot
+ ]);
+in {
+ options.services.cook-cli = {
+ enable = mkEnableOption "cook-cli webserver";
+ package = mkOption {
+ type = types.package;
+ default = pcfg.package;
+ description = ''
+ cook-cli package. It is recommended to set this only in programs.cook-cli
+ '';
+ };
+
+ recipeRoot = mkOption {
+ type = types.path;
+ default = "${config.xdg.dataHome}/cookbook";
+ };
+
+ port = mkOption {
+ type = types.port;
+ defulat = 9080;
+ };
+
+ extraArgs = mkOption {
+ type = with types; listOf str;
+ default = [];
+ };
+ };
+
+ config = mkIf cfg.enable {
+ systemd.user.services.cook-cli = {
+ Unit = {
+ Description = "A website for serving cooklang cookbooks";
+ After = [ "network.target" ];
+ };
+ Service = {
+ Restart = "on-failure";
+ RestartSec = 10;
+ Type = "simple";
+ ExecStart = "${getExe cfg.package} server ${args}";
+ };
+ Install = {
+ WantedBy = [ "default.target" ];
+ };
+ };
+ };
+}