diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-03-22 12:26:11 -0500 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-03-22 12:26:11 -0500 |
| commit | b66fa26eaad3fcbf92af680b686f3d2680539128 (patch) | |
| tree | 0dfd7acd75087f3791325c134911723cc18fa3c4 /modules/home-manager/cook-cli | |
| download | cooklang-nix-b66fa26eaad3fcbf92af680b686f3d2680539128.tar cooklang-nix-b66fa26eaad3fcbf92af680b686f3d2680539128.tar.gz cooklang-nix-b66fa26eaad3fcbf92af680b686f3d2680539128.tar.bz2 cooklang-nix-b66fa26eaad3fcbf92af680b686f3d2680539128.tar.lz cooklang-nix-b66fa26eaad3fcbf92af680b686f3d2680539128.tar.xz cooklang-nix-b66fa26eaad3fcbf92af680b686f3d2680539128.tar.zst cooklang-nix-b66fa26eaad3fcbf92af680b686f3d2680539128.zip | |
Adding to repo
Diffstat (limited to 'modules/home-manager/cook-cli')
| -rw-r--r-- | modules/home-manager/cook-cli/default.nix | 6 | ||||
| -rw-r--r-- | modules/home-manager/cook-cli/program.nix | 14 | ||||
| -rw-r--r-- | modules/home-manager/cook-cli/service.nix | 56 |
3 files changed, 76 insertions, 0 deletions
diff --git a/modules/home-manager/cook-cli/default.nix b/modules/home-manager/cook-cli/default.nix new file mode 100644 index 0000000..f42e210 --- /dev/null +++ b/modules/home-manager/cook-cli/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./program.nix + ./service.nix + ]; +} diff --git a/modules/home-manager/cook-cli/program.nix b/modules/home-manager/cook-cli/program.nix new file mode 100644 index 0000000..e31187f --- /dev/null +++ b/modules/home-manager/cook-cli/program.nix @@ -0,0 +1,14 @@ +{ config, pkgs, lib, ... }: +with builtins // lib; +let + cfg = config.programs.cook-cli; +in { + options.programs.cook-cli = { + enable = mkEnableOption "cook-cli"; + package = mkPackageOption pkgs "cook-cli" {}; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + }; +} 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" ]; + }; + }; + }; +} |
