fork/home-manager

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

ilaumjdscmpuff: enable or disable aliases55ce64c3

master
1.8 KiB72 linesraw
1{ config, lib, pkgs, ... }:
2with lib;
3let cfg = config.programs.scmpuff;
4in {
5  meta.maintainers = [ maintainers.cpcloud ];
6
7  options.programs.scmpuff = {
8    enable = mkEnableOption ''
9      scmpuff, a command line tool that allows you to work quicker with Git by
10      substituting numeric shortcuts for files'';
11
12    package = mkOption {
13      type = types.package;
14      default = pkgs.scmpuff;
15      defaultText = literalExpression "pkgs.scmpuff";
16      description = "Package providing the {command}`scmpuff` tool.";
17    };
18
19    enableBashIntegration = mkOption {
20      default = true;
21      type = types.bool;
22      description = ''
23        Whether to enable Bash integration.
24      '';
25    };
26
27    enableZshIntegration = mkOption {
28      default = true;
29      type = types.bool;
30      description = ''
31        Whether to enable Zsh integration.
32      '';
33    };
34
35    enableFishIntegration = mkOption {
36      default = true;
37      type = types.bool;
38      description = ''
39        Whether to enable fish integration.
40      '';
41    };
42
43    enableAliases = mkOption {
44      default = true;
45      type = types.bool;
46      description = ''
47        Whether to enable aliases (e.g. gs, ga, gd, gco).
48      '';
49    };
50  };
51
52  config = mkIf cfg.enable (let
53    mkArgs = shell:
54      concatStringsSep " " ([ "--shell=${shell}" ]
55        ++ optional (!cfg.enableAliases) "--aliases=false");
56  in {
57    home.packages = [ cfg.package ];
58
59    programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
60      eval "$(${cfg.package}/bin/scmpuff init ${mkArgs "bash"})"
61    '';
62
63    programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
64      eval "$(${cfg.package}/bin/scmpuff init ${mkArgs "zsh"})"
65    '';
66
67    programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration
68      (mkAfter ''
69        ${cfg.package}/bin/scmpuff init ${mkArgs "fish"} | source
70      '');
71  });
72}