1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-26 08:28:30 +02:00

fish: basic completions support

This commit is contained in:
Jonas Holst Damtoft 2019-04-12 12:33:51 +02:00 committed by Robert Helgesson
parent b18d302d44
commit c22f3e1d29
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89

View File

@ -14,13 +14,13 @@ let
mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases
);
fileType = types.submodule (
fileType = textGen: types.submodule (
{ name, config, ... }: {
options = {
body = mkOption {
default = null;
type = types.nullOr types.lines;
description = "Body of the function.";
description = "Body of the file.";
};
source = mkOption {
@ -36,11 +36,7 @@ let
source = mkIf (config.body != null) (
mkDefault (pkgs.writeTextFile {
inherit name;
text = ''
function ${name}
${config.body}
end
'';
text = textGen name config.body;
executable = true;
})
);
@ -125,12 +121,24 @@ in
};
programs.fish.functions = mkOption {
type = types.attrsOf fileType;
type = types.attrsOf (fileType (name: body: ''
function ${name}
${body}
end
''));
default = {};
description = ''
Functions to add to fish.
'';
};
programs.fish.completions = mkOption {
type = types.attrsOf (fileType (name: body: body));
default = {};
description = ''
Completions to add to fish.
'';
};
};
config = mkIf cfg.enable (mkMerge [{