fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.6 KiB60 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.lazygit;
8
9  yamlFormat = pkgs.formats.yaml { };
10
11  inherit (pkgs.stdenv.hostPlatform) isDarwin;
12
13in {
14  meta.maintainers = [ hm.maintainers.kalhauge ];
15
16  options.programs.lazygit = {
17    enable = mkEnableOption "lazygit, a simple terminal UI for git commands";
18
19    package = mkPackageOption pkgs "lazygit" { };
20
21    settings = mkOption {
22      type = yamlFormat.type;
23      default = { };
24      defaultText = literalExpression "{ }";
25      example = literalExpression ''
26        {
27          gui.theme = {
28            lightTheme = true;
29            activeBorderColor = [ "blue" "bold" ];
30            inactiveBorderColor = [ "black" ];
31            selectedLineBgColor = [ "default" ];
32          };
33        }
34      '';
35      description = ''
36        Configuration written to
37        {file}`$XDG_CONFIG_HOME/lazygit/config.yml`
38        on Linux or on Darwin if [](#opt-xdg.enable) is set, otherwise
39        {file}`~/Library/Application Support/lazygit/config.yml`.
40        See
41        <https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md>
42        for supported values.
43      '';
44    };
45  };
46
47  config = mkIf cfg.enable {
48    home.packages = [ cfg.package ];
49
50    home.file."Library/Application Support/lazygit/config.yml" =
51      mkIf (cfg.settings != { } && (isDarwin && !config.xdg.enable)) {
52        source = yamlFormat.generate "lazygit-config" cfg.settings;
53      };
54
55    xdg.configFile."lazygit/config.yml" =
56      mkIf (cfg.settings != { } && !(isDarwin && !config.xdg.enable)) {
57        source = yamlFormat.generate "lazygit-config" cfg.settings;
58      };
59  };
60}