fork/home-manager

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

Matt Moriarityjujutsu: fix zsh completion (#4305)a4f45087

master
1.9 KiB76 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.jujutsu;
8  tomlFormat = pkgs.formats.toml { };
9
10in {
11  meta.maintainers = [ maintainers.shikanime ];
12
13  options.programs.jujutsu = {
14    enable =
15      mkEnableOption "a Git-compatible DVCS that is both simple and powerful";
16
17    package = mkPackageOption pkgs "jujutsu" { };
18
19    settings = mkOption {
20      type = tomlFormat.type;
21      default = { };
22      example = literalExpression ''
23        {
24          user = {
25            name = "John Doe";
26            email = "jdoe@example.org";
27          };
28        }
29      '';
30      description = ''
31        Options to add to the {file}`.jjconfig.toml` file. See
32        <https://github.com/martinvonz/jj/blob/main/docs/config.md>
33        for options.
34      '';
35    };
36
37    enableBashIntegration = mkOption {
38      type = types.bool;
39      default = true;
40      description = "Whether to enable Bash integration.";
41    };
42
43    enableZshIntegration = mkOption {
44      type = types.bool;
45      default = true;
46      description = "Whether to enable Zsh integration.";
47    };
48
49    enableFishIntegration = mkOption {
50      type = types.bool;
51      default = true;
52      description = "Whether to enable Fish integration.";
53    };
54  };
55
56  config = mkIf cfg.enable {
57    home.packages = [ cfg.package ];
58
59    home.file.".jjconfig.toml" = mkIf (cfg.settings != { }) {
60      source = tomlFormat.generate "jujutsu-config" cfg.settings;
61    };
62
63    programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
64      source <(${pkgs.jujutsu}/bin/jj util completion)
65    '';
66
67    programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
68      source <(${pkgs.jujutsu}/bin/jj util completion --zsh)
69      compdef _jj ${pkgs.jujutsu}/bin/jj
70    '';
71
72    programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
73      ${pkgs.jujutsu}/bin/jj util completion --fish | source
74    '';
75  };
76}