aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/fi/fish/module.nix
blob: 42746c5c1c7d0c1cea47d69c6d2ec12609499970 (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
  config,
  lib,
  ...
}: let
  cfg = config.soispha.programs.fish;

  sourceFile = path: "source ${path}\n";

  extraFiles = builtins.concatStringsSep "\n" (
    builtins.map (value:
      if builtins.isPath value
      then (sourceFile value)
      else value) (
      builtins.attrValues cfg.integrations
    )
  );
in {
  options.soispha.programs.fish = {
    enable = lib.mkEnableOption "fish";

    integrations = lib.mkOption {
      type = lib.types.attrsOf (lib.types.either lib.types.path lib.types.str);
      example = ''
        {
          atuin = ./integrations/atuin.fish;
        }
      '';
      default = {};
    };
  };

  config = lib.mkIf cfg.enable {
    home-manager.users.soispha = {
      home.sessionPath = lib.mkForce [];

      programs.fish = {
        enable = true;

        interactiveShellInit = let
          start = lib.modules.mkBefore (
            sourceFile ./config/01_show-task.fish
          );
          end = lib.modules.mkAfter (
            sourceFile ./config/keybindings/00__start.fish
            + sourceFile ./config/keybindings/01_insert.fish
            + sourceFile ./config/keybindings/02_command.fish
            + sourceFile ./config/keybindings/03_visual.fish
            + sourceFile ./config/keybindings/04_replace.fish
            + sourceFile ./config/keybindings/05_operator.fish
            + sourceFile ./config/keybindings/06_replace_one.fish
            + sourceFile ./config/keybindings/07_others.fish
            + sourceFile ./config/keybindings/08__end.fish
          );
        in
          lib.modules.mkMerge
          [
            start

            extraFiles

            end
          ];
      };
    };
  };
}