aboutsummaryrefslogtreecommitdiff
path: root/modules/home-manager/cooklang-chef/program.nix
blob: 4cbed5ce540ecd444bf78d1caa8e04da52d7ac8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ 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;
      };
    };
  };
}