fork/home-manager

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

mat essfish: always run fish_indent7e81e7ae

master
1.6 KiB64 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  fooPluginSrc = pkgs.writeText "fooPluginSrc" "";
8
9  generatedConfdFile = pkgs.writeText "plugin-foo.fish" ''
10    # Plugin foo
11    set -l plugin_dir ${fooPluginSrc}
12
13    # Set paths to import plugin components
14    if test -d $plugin_dir/functions
15        set fish_function_path $fish_function_path[1] $plugin_dir/functions $fish_function_path[2..-1]
16    end
17
18    if test -d $plugin_dir/completions
19        set fish_complete_path $fish_complete_path[1] $plugin_dir/completions $fish_complete_path[2..-1]
20    end
21
22    # Source initialization code if it exists.
23    if test -d $plugin_dir/conf.d
24        for f in $plugin_dir/conf.d/*.fish
25            source $f
26        end
27    end
28
29    if test -f $plugin_dir/key_bindings.fish
30        source $plugin_dir/key_bindings.fish
31    end
32
33    if test -f $plugin_dir/init.fish
34        source $plugin_dir/init.fish
35    end
36  '';
37
38in {
39  config = {
40    programs.fish = {
41      enable = true;
42
43      plugins = [{
44        name = "foo";
45        src = fooPluginSrc;
46      }];
47    };
48
49    # Needed to avoid error with dummy fish package.
50    xdg.dataFile."fish/home-manager_generated_completions".source =
51      lib.mkForce (builtins.toFile "empty" "");
52
53    nmt = {
54      description =
55        "if fish.plugins set, check conf.d file exists and contents match";
56      script = ''
57        assertDirectoryExists home-files/.config/fish/conf.d
58        assertFileExists home-files/.config/fish/conf.d/plugin-foo.fish
59        assertFileContent home-files/.config/fish/conf.d/plugin-foo.fish ${generatedConfdFile}
60      '';
61
62    };
63  };
64}