mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +01:00
fish: apply nixfmt
This commit is contained in:
parent
57bd27b3e7
commit
543118ac70
2 changed files with 97 additions and 107 deletions
1
format
1
format
|
@ -39,7 +39,6 @@ find . -name '*.nix' \
|
|||
! -path ./modules/programs/bash.nix \
|
||||
! -path ./modules/programs/emacs.nix \
|
||||
! -path ./modules/programs/firefox.nix \
|
||||
! -path ./modules/programs/fish.nix \
|
||||
! -path ./modules/programs/gpg.nix \
|
||||
! -path ./modules/programs/lesspipe.nix \
|
||||
! -path ./modules/programs/neovim.nix \
|
||||
|
|
|
@ -36,9 +36,7 @@ let
|
|||
aliasesStr = concatStringsSep "\n"
|
||||
(mapAttrsToList (k: v: "alias ${k} ${escapeShellArg v}") cfg.shellAliases);
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
in {
|
||||
options = {
|
||||
programs.fish = {
|
||||
enable = mkEnableOption "fish, the friendly interactive shell";
|
||||
|
@ -55,7 +53,10 @@ in
|
|||
shellAliases = mkOption {
|
||||
type = with types; attrsOf str;
|
||||
default = { };
|
||||
example = { ".." = "cd .."; ll = "ls -l"; };
|
||||
example = {
|
||||
".." = "cd ..";
|
||||
ll = "ls -l";
|
||||
};
|
||||
description = ''
|
||||
An attribute set that maps aliases (the top level attribute names
|
||||
in this option) to command strings or directly to build outputs.
|
||||
|
@ -158,26 +159,20 @@ in
|
|||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [{
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.dataFile."fish/home-manager_generated_completions".source =
|
||||
let
|
||||
xdg.dataFile."fish/home-manager_generated_completions".source = let
|
||||
# paths later in the list will overwrite those already linked
|
||||
destructiveSymlinkJoin =
|
||||
args_@{ name
|
||||
, paths
|
||||
, preferLocalBuild ? true
|
||||
, allowSubstitutes ? false
|
||||
, postBuild ? ""
|
||||
, ...
|
||||
}:
|
||||
destructiveSymlinkJoin = args_@{ name, paths, preferLocalBuild ? true
|
||||
, allowSubstitutes ? false, postBuild ? "", ... }:
|
||||
let
|
||||
args = removeAttrs args_ [ "name" "postBuild" ]
|
||||
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
|
||||
in pkgs.runCommand name args
|
||||
''
|
||||
args = removeAttrs args_ [ "name" "postBuild" ] // {
|
||||
# pass the defaults
|
||||
inherit preferLocalBuild allowSubstitutes;
|
||||
};
|
||||
in pkgs.runCommand name args ''
|
||||
mkdir -p $out
|
||||
for i in $paths; do
|
||||
if [ -z "$(find $i -prune -empty)" ]; then
|
||||
|
@ -186,16 +181,15 @@ in
|
|||
done
|
||||
${postBuild}
|
||||
'';
|
||||
generateCompletions = package: pkgs.runCommand
|
||||
"${package.name}-fish-completions"
|
||||
{
|
||||
|
||||
generateCompletions = package:
|
||||
pkgs.runCommand "${package.name}-fish-completions" {
|
||||
src = package;
|
||||
nativeBuildInputs = [ pkgs.python2 ];
|
||||
buildInputs = [ cfg.package ];
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
}
|
||||
''
|
||||
} ''
|
||||
mkdir -p $out
|
||||
if [ -d $src/share/man ]; then
|
||||
find $src/share/man -type f \
|
||||
|
@ -203,14 +197,11 @@ in
|
|||
> /dev/null
|
||||
fi
|
||||
'';
|
||||
in
|
||||
destructiveSymlinkJoin {
|
||||
in destructiveSymlinkJoin {
|
||||
name = "${config.home.username}-fish-completions";
|
||||
paths =
|
||||
let
|
||||
cmp = (a: b: (a.meta.priority or 0) > (b.meta.priority or 0));
|
||||
in
|
||||
map generateCompletions (sort cmp config.home.packages);
|
||||
let cmp = (a: b: (a.meta.priority or 0) > (b.meta.priority or 0));
|
||||
in map generateCompletions (sort cmp config.home.packages);
|
||||
};
|
||||
|
||||
programs.fish.interactiveShellInit = ''
|
||||
|
@ -279,25 +270,25 @@ in
|
|||
|
||||
end
|
||||
'';
|
||||
|
||||
} {
|
||||
|
||||
}
|
||||
{
|
||||
xdg.configFile = mapAttrs' (fName: fBody: {
|
||||
name = "fish/functions/${fName}.fish";
|
||||
value = {"text" = ''
|
||||
value = {
|
||||
"text" = ''
|
||||
function ${fName}
|
||||
${fBody}
|
||||
end
|
||||
'';};
|
||||
'';
|
||||
};
|
||||
}) cfg.functions;
|
||||
|
||||
}
|
||||
|
||||
# Each plugin gets a corresponding conf.d/plugin-NAME.fish file to load
|
||||
# in the paths and any initialization scripts.
|
||||
(mkIf (length cfg.plugins > 0) {
|
||||
xdg.configFile = mkMerge (
|
||||
(map (plugin: { "fish/conf.d/plugin-${plugin.name}.fish".text = ''
|
||||
xdg.configFile = mkMerge ((map (plugin: {
|
||||
"fish/conf.d/plugin-${plugin.name}.fish".text = ''
|
||||
# Plugin ${plugin.name}
|
||||
set -l plugin_dir ${plugin.src}
|
||||
|
||||
|
|
Loading…
Reference in a new issue