fork/home-manager

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

mat essfish: always run fish_indent7e81e7ae

master
1.2 KiB52 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  func = pkgs.writeText "func.fish" ''
8    function func
9        echo Hello
10    end
11  '';
12
13  funcEvent = pkgs.writeText "func-event.fish" ''
14    function func-event --on-event="fish_command_not_found"
15        echo "Not found!"
16    end
17  '';
18
19in {
20  config = {
21    programs.fish = {
22      enable = true;
23
24      functions = {
25        func = ''echo "Hello"'';
26        func-event = {
27          body = ''echo "Not found!"'';
28          onEvent = "fish_command_not_found";
29        };
30      };
31    };
32
33    # Needed to avoid error with dummy fish package.
34    xdg.dataFile."fish/home-manager_generated_completions".source =
35      lib.mkForce (builtins.toFile "empty" "");
36
37    nmt = {
38      description =
39        "if fish.function is set, check file exists and contents match";
40      script = ''
41        assertFileExists home-files/.config/fish/functions/func.fish
42        echo ${func}
43        assertFileContent home-files/.config/fish/functions/func.fish ${func}
44
45        assertFileExists home-files/.config/fish/functions/func-event.fish
46        echo ${funcEvent}
47        assertFileContent home-files/.config/fish/functions/func-event.fish ${funcEvent}
48      '';
49
50    };
51  };
52}