mirror of
https://github.com/nix-community/home-manager
synced 2024-11-01 00:39:45 +01:00
cb09a968e9
This option provides a more convenient way to overlay dummy packages. It also adds a function `config.lib.test.mkStubPackage` that can, e.g., be used for `package` options.
54 lines
1.2 KiB
Nix
54 lines
1.2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
func = pkgs.writeText "func.fish" ''
|
|
function func
|
|
echo "Hello"
|
|
end
|
|
'';
|
|
|
|
funcEvent = pkgs.writeText "func-event.fish" ''
|
|
function func-event --on-event="fish_command_not_found"
|
|
echo "Not found!"
|
|
end
|
|
'';
|
|
|
|
in {
|
|
config = {
|
|
programs.fish = {
|
|
enable = true;
|
|
|
|
functions = {
|
|
func = ''echo "Hello"'';
|
|
func-event = {
|
|
body = ''echo "Not found!"'';
|
|
onEvent = "fish_command_not_found";
|
|
};
|
|
};
|
|
};
|
|
|
|
# Needed to avoid error with dummy fish package.
|
|
xdg.dataFile."fish/home-manager_generated_completions".source =
|
|
lib.mkForce (builtins.toFile "empty" "");
|
|
|
|
test.stubs.fish = { };
|
|
|
|
nmt = {
|
|
description =
|
|
"if fish.function is set, check file exists and contents match";
|
|
script = ''
|
|
assertFileExists home-files/.config/fish/functions/func.fish
|
|
echo ${func}
|
|
assertFileContent home-files/.config/fish/functions/func.fish ${func}
|
|
|
|
assertFileExists home-files/.config/fish/functions/func-event.fish
|
|
echo ${funcEvent}
|
|
assertFileContent home-files/.config/fish/functions/func-event.fish ${funcEvent}
|
|
'';
|
|
|
|
};
|
|
};
|
|
}
|