{ config, pkgs, lib, ... }: with builtins // lib; let cfg = config.programs.cooklang-chef; toml = pkgs.formats.toml {}; in { options.programs.cooklang-chef = { enable = mkEnableOption "cooklang-chef"; package = mkPackageOption pkgs "cooklang-chef" {}; settings = mkOption { type = toml.type; default = {}; description = "https://github.com/Zheoni/cooklang-chef/blob/main/docs/cli.md"; }; }; config = mkIf cfg.enable { home.packages = [ cfg.package ]; programs.cooklang-chef.settings = { default_collection = mkDefault "${config.xdg.dataHome}/cookbook"; }; xdg.configFile = { "cooklang-chef/chef-config.toml" = mkIf (cfg.settings != {}) { source = toml.generate "chef-config.toml" cfg.settings; }; }; }; }