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