From c083b27791daabbee7c4d67f5315ff5c877f1076 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 28 Dec 2020 21:14:26 +0100 Subject: fishPlugins: bootstrap fish plugin scope --- pkgs/shells/fish/plugins/build-fish-plugin.nix | 77 ++++++++++++++++++++++++++ pkgs/shells/fish/plugins/default.nix | 7 +++ 2 files changed, 84 insertions(+) create mode 100644 pkgs/shells/fish/plugins/build-fish-plugin.nix create mode 100644 pkgs/shells/fish/plugins/default.nix (limited to 'pkgs/shells/fish') diff --git a/pkgs/shells/fish/plugins/build-fish-plugin.nix b/pkgs/shells/fish/plugins/build-fish-plugin.nix new file mode 100644 index 000000000000..e2ec342e5440 --- /dev/null +++ b/pkgs/shells/fish/plugins/build-fish-plugin.nix @@ -0,0 +1,77 @@ +{ stdenv, lib, writeShellScriptBin, writeScript, fish }: + +let + rtpPath = "share/fish"; + + mapToFuncPath = v: + if lib.isString v + then v + else "${v}/${rtpPath}/vendor_functions.d"; + + fishWithFunctionPath = plugins: let + funcPaths = map mapToFuncPath plugins; + in writeShellScriptBin "fish" '' + ${fish}/bin/fish \ + --init-command \ + "set --prepend fish_function_path ${lib.escapeShellArgs funcPaths}" \ + "$@" + ''; + +in attrs@{ + pname, + version, + src, + + name ? "fishplugin-${pname}-${version}", + unpackPhase ? "", + configurePhase ? ":", + buildPhase ? ":", + preInstall ? "", + postInstall ? "", + # name of the subdirectory in which to store the plugin + installPath ? lib.getName pname, + + checkInputs ? [], + # plugins or paths to add to the function path of the test fish shell + checkFunctionPath ? [], + # test script to be executed in a fish shell + checkPhase ? "", + doCheck ? checkPhase != "", + + ... +}: + +stdenv.mkDerivation (attrs // { + inherit name; + inherit unpackPhase configurePhase buildPhase; + + inherit preInstall postInstall; + installPhase = '' + runHook preInstall + + ( + install_vendor_files() { + source="$1" + target="$out/${rtpPath}/vendor_$2.d" + + [ -d $source ] || return 0 + mkdir -p $target + cp -r $source/*.fish "$target/" + } + + install_vendor_files completions completions + install_vendor_files functions functions + install_vendor_files conf conf + install_vendor_files conf.d conf + ) + + runHook postInstall + ''; + + inherit doCheck; + checkInputs = [ (fishWithFunctionPath checkFunctionPath) ] ++ checkInputs; + checkPhase = '' + export HOME=$(mktemp -d) # fish wants a writable home + fish "${writeScript "${name}-test" checkPhase}" + ''; +}) diff --git a/pkgs/shells/fish/plugins/default.nix b/pkgs/shells/fish/plugins/default.nix new file mode 100644 index 000000000000..95bf6504bbed --- /dev/null +++ b/pkgs/shells/fish/plugins/default.nix @@ -0,0 +1,7 @@ +{ lib, newScope }: + +lib.makeScope newScope (self: with self; { + + buildFishPlugin = callPackage ./build-fish-plugin.nix { }; + +}) -- cgit 1.4.1 From 3a987feae1ac17a4e1d373615610c83f4110628b Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 28 Dec 2020 21:15:08 +0100 Subject: fishPlugins.fishtape: init at 2.1.3 --- pkgs/shells/fish/plugins/default.nix | 2 ++ pkgs/shells/fish/plugins/fishtape.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 pkgs/shells/fish/plugins/fishtape.nix (limited to 'pkgs/shells/fish') diff --git a/pkgs/shells/fish/plugins/default.nix b/pkgs/shells/fish/plugins/default.nix index 95bf6504bbed..b6b5abb485d1 100644 --- a/pkgs/shells/fish/plugins/default.nix +++ b/pkgs/shells/fish/plugins/default.nix @@ -4,4 +4,6 @@ lib.makeScope newScope (self: with self; { buildFishPlugin = callPackage ./build-fish-plugin.nix { }; + fishtape = callPackage ./fishtape.nix { }; + }) diff --git a/pkgs/shells/fish/plugins/fishtape.nix b/pkgs/shells/fish/plugins/fishtape.nix new file mode 100644 index 000000000000..326ff61c4174 --- /dev/null +++ b/pkgs/shells/fish/plugins/fishtape.nix @@ -0,0 +1,32 @@ +{ lib, buildFishPlugin, fetchFromGitHub }: + +buildFishPlugin rec { + pname = "fishtape"; + version = "2.1.3"; + + src = fetchFromGitHub { + owner = "jorgebucaran"; + repo = "fishtape"; + rev = version; + sha256 = "0dxcyhs2shhgy5xnwcimqja8vqsyk841x486lgq13i3y1h0kp2kd"; + }; + + checkFunctionPath = [ "./" ]; # fishtape is introspective + checkPhase = '' + rm test/tty.fish # test expects a tty + fishtape test/*.fish + ''; + + preInstall = '' + # move the function script in the proper sub-directory + mkdir functions + mv fishtape.fish functions/ + ''; + + meta = { + description = "TAP-based test runner for Fish"; + homepage = "https://github.com/jorgebucaran/fishtape"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ pacien ]; + }; +} -- cgit 1.4.1 From 59c1b6d0e770640758e8585f9bd1c8f98a59174a Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 28 Dec 2020 21:15:57 +0100 Subject: fishPlugins.pure: init at 3.4.2 --- pkgs/shells/fish/plugins/default.nix | 2 ++ pkgs/shells/fish/plugins/pure.nix | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 pkgs/shells/fish/plugins/pure.nix (limited to 'pkgs/shells/fish') diff --git a/pkgs/shells/fish/plugins/default.nix b/pkgs/shells/fish/plugins/default.nix index b6b5abb485d1..42ba860e8c55 100644 --- a/pkgs/shells/fish/plugins/default.nix +++ b/pkgs/shells/fish/plugins/default.nix @@ -6,4 +6,6 @@ lib.makeScope newScope (self: with self; { fishtape = callPackage ./fishtape.nix { }; + pure = callPackage ./pure.nix { }; + }) diff --git a/pkgs/shells/fish/plugins/pure.nix b/pkgs/shells/fish/plugins/pure.nix new file mode 100644 index 000000000000..54af2e0663e8 --- /dev/null +++ b/pkgs/shells/fish/plugins/pure.nix @@ -0,0 +1,29 @@ +{ lib, buildFishPlugin, fetchFromGitHub, git, fishtape }: + +buildFishPlugin rec { + pname = "pure"; + version = "3.4.2"; + + src = fetchFromGitHub { + owner = "rafaelrinaldi"; + repo = "pure"; + rev = "v${version}"; + sha256 = "134sz3f98gb6z2vgd5kkm6dd8pka5gijk843c32s616w35y07sga"; + }; + + checkInputs = [ git ]; + checkFunctionPath = [ fishtape ]; + checkPhase = '' + # https://github.com/rafaelrinaldi/pure/issues/264 + rm tests/_pure_string_width.test.fish + + fishtape tests/*.test.fish + ''; + + meta = { + description = "Pretty, minimal and fast Fish prompt, ported from zsh"; + homepage = "https://github.com/rafaelrinaldi/pure"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ pacien ]; + }; +} -- cgit 1.4.1 From d94921db12d9c9e2d3e9c2e6e25e50f03f789ecb Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 29 Dec 2020 09:44:18 +0100 Subject: fish-foreign-env: move to fishPlugins.foreign-env And relocate the installed fish functions to the `vendor_functions.d` so that they're automatically loaded. --- nixos/doc/manual/release-notes/rl-2103.xml | 8 ++++++ nixos/modules/programs/fish.nix | 8 +++--- pkgs/shells/fish/fish-foreign-env/default.nix | 31 ---------------------- .../suppress-harmless-warnings.patch | 23 ---------------- pkgs/shells/fish/plugins/default.nix | 2 ++ pkgs/shells/fish/plugins/foreign-env/default.nix | 29 ++++++++++++++++++++ .../foreign-env/suppress-harmless-warnings.patch | 23 ++++++++++++++++ pkgs/top-level/aliases.nix | 1 + pkgs/top-level/all-packages.nix | 2 -- 9 files changed, 67 insertions(+), 60 deletions(-) delete mode 100644 pkgs/shells/fish/fish-foreign-env/default.nix delete mode 100644 pkgs/shells/fish/fish-foreign-env/suppress-harmless-warnings.patch create mode 100644 pkgs/shells/fish/plugins/foreign-env/default.nix create mode 100644 pkgs/shells/fish/plugins/foreign-env/suppress-harmless-warnings.patch (limited to 'pkgs/shells/fish') diff --git a/nixos/doc/manual/release-notes/rl-2103.xml b/nixos/doc/manual/release-notes/rl-2103.xml index 432de831cb67..dbc4ecd6930e 100644 --- a/nixos/doc/manual/release-notes/rl-2103.xml +++ b/nixos/doc/manual/release-notes/rl-2103.xml @@ -309,6 +309,14 @@ Based on , existing installations will continue to work. + + + fish-foreign-env is now an alias for the + fishPlugins.foreign-env package, in which the fish + functions have been relocated to the + vendor_functions.d directory to be loaded automatically. + + The prometheus json exporter is now managed by the prometheus community. Together with additional features diff --git a/nixos/modules/programs/fish.nix b/nixos/modules/programs/fish.nix index 50d1077dd410..34a0dc6a2df3 100644 --- a/nixos/modules/programs/fish.nix +++ b/nixos/modules/programs/fish.nix @@ -112,7 +112,7 @@ in environment.etc."fish/nixos-env-preinit.fish".text = '' # This happens before $__fish_datadir/config.fish sets fish_function_path, so it is currently # unset. We set it and then completely erase it, leaving its configuration to $__fish_datadir/config.fish - set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $__fish_datadir/functions + set fish_function_path ${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d $__fish_datadir/functions # source the NixOS environment config if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ] @@ -128,7 +128,7 @@ in # if we haven't sourced the general config, do it if not set -q __fish_nixos_general_config_sourced - set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path + set --prepend fish_function_path ${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d fenv source /etc/fish/foreign-env/shellInit > /dev/null set -e fish_function_path[1] @@ -142,7 +142,7 @@ in # if we haven't sourced the login config, do it status --is-login; and not set -q __fish_nixos_login_config_sourced and begin - set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path + set --prepend fish_function_path ${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d fenv source /etc/fish/foreign-env/loginShellInit > /dev/null set -e fish_function_path[1] @@ -158,7 +158,7 @@ in and begin ${fishAliases} - set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path + set --prepend fish_function_path ${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d fenv source /etc/fish/foreign-env/interactiveShellInit > /dev/null set -e fish_function_path[1] diff --git a/pkgs/shells/fish/fish-foreign-env/default.nix b/pkgs/shells/fish/fish-foreign-env/default.nix deleted file mode 100644 index ef157f323923..000000000000 --- a/pkgs/shells/fish/fish-foreign-env/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ stdenv, fetchFromGitHub, gnused, bash, coreutils }: - -stdenv.mkDerivation { - pname = "fish-foreign-env"; - version = "git-20200209"; - - src = fetchFromGitHub { - owner = "oh-my-fish"; - repo = "plugin-foreign-env"; - rev = "dddd9213272a0ab848d474d0cbde12ad034e65bc"; - sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"; - }; - - installPhase = '' - mkdir -p $out/share/fish-foreign-env/functions/ - cp functions/* $out/share/fish-foreign-env/functions/ - sed -e "s|sed|${gnused}/bin/sed|" \ - -e "s|bash|${bash}/bin/bash|" \ - -e "s|\| tr|\| ${coreutils}/bin/tr|" \ - -i $out/share/fish-foreign-env/functions/* - ''; - - patches = [ ./suppress-harmless-warnings.patch ]; - - meta = with stdenv.lib; { - description = "A foreign environment interface for Fish shell"; - license = licenses.mit; - maintainers = with maintainers; [ jgillich ]; - platforms = with platforms; unix; - }; -} diff --git a/pkgs/shells/fish/fish-foreign-env/suppress-harmless-warnings.patch b/pkgs/shells/fish/fish-foreign-env/suppress-harmless-warnings.patch deleted file mode 100644 index 6eed35152120..000000000000 --- a/pkgs/shells/fish/fish-foreign-env/suppress-harmless-warnings.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/functions/fenv.apply.fish b/functions/fenv.apply.fish -index 34a25e3..3d94135 100644 ---- a/functions/fenv.apply.fish -+++ b/functions/fenv.apply.fish -@@ -27,11 +27,17 @@ function fenv.apply - for variable in $variables - set key (echo $variable | sed 's/=.*//') - set value (echo $variable | sed 's/[^=]*=//') -+ set ignore PATH _ - - if test "$key" = 'PATH' - set value (echo $value | tr ':' '\n') - end - -- set -g -x $key $value -+ if contains $key $ignore -+ set -g -x $key $value 2>/dev/null -+ else -+ set -g -x $key $value -+ end -+ - end - end diff --git a/pkgs/shells/fish/plugins/default.nix b/pkgs/shells/fish/plugins/default.nix index 42ba860e8c55..e543d49516a8 100644 --- a/pkgs/shells/fish/plugins/default.nix +++ b/pkgs/shells/fish/plugins/default.nix @@ -6,6 +6,8 @@ lib.makeScope newScope (self: with self; { fishtape = callPackage ./fishtape.nix { }; + foreign-env = callPackage ./foreign-env { }; + pure = callPackage ./pure.nix { }; }) diff --git a/pkgs/shells/fish/plugins/foreign-env/default.nix b/pkgs/shells/fish/plugins/foreign-env/default.nix new file mode 100644 index 000000000000..03435340d179 --- /dev/null +++ b/pkgs/shells/fish/plugins/foreign-env/default.nix @@ -0,0 +1,29 @@ +{ lib, buildFishPlugin, fetchFromGitHub, gnused, bash, coreutils }: + +buildFishPlugin { + pname = "foreign-env"; + version = "git-20200209"; + + src = fetchFromGitHub { + owner = "oh-my-fish"; + repo = "plugin-foreign-env"; + rev = "dddd9213272a0ab848d474d0cbde12ad034e65bc"; + sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"; + }; + + patches = [ ./suppress-harmless-warnings.patch ]; + + preInstall = '' + sed -e "s|sed|${gnused}/bin/sed|" \ + -e "s|bash|${bash}/bin/bash|" \ + -e "s|\| tr|\| ${coreutils}/bin/tr|" \ + -i functions/* + ''; + + meta = with lib; { + description = "A foreign environment interface for Fish shell"; + license = licenses.mit; + maintainers = with maintainers; [ jgillich ]; + platforms = with platforms; unix; + }; +} diff --git a/pkgs/shells/fish/plugins/foreign-env/suppress-harmless-warnings.patch b/pkgs/shells/fish/plugins/foreign-env/suppress-harmless-warnings.patch new file mode 100644 index 000000000000..6eed35152120 --- /dev/null +++ b/pkgs/shells/fish/plugins/foreign-env/suppress-harmless-warnings.patch @@ -0,0 +1,23 @@ +diff --git a/functions/fenv.apply.fish b/functions/fenv.apply.fish +index 34a25e3..3d94135 100644 +--- a/functions/fenv.apply.fish ++++ b/functions/fenv.apply.fish +@@ -27,11 +27,17 @@ function fenv.apply + for variable in $variables + set key (echo $variable | sed 's/=.*//') + set value (echo $variable | sed 's/[^=]*=//') ++ set ignore PATH _ + + if test "$key" = 'PATH' + set value (echo $value | tr ':' '\n') + end + +- set -g -x $key $value ++ if contains $key $ignore ++ set -g -x $key $value 2>/dev/null ++ else ++ set -g -x $key $value ++ end ++ + end + end diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 4a4277c20729..01c80ea3d804 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -158,6 +158,7 @@ mapAliases ({ firefoxWrapper = firefox; # 2015-09 firestr = throw "firestr has been removed."; # added 2019-12-08 + fish-foreign-env = fishPlugins.foreign-env; # added 2020-12-29 flameGraph = flamegraph; # added 2018-04-25 flvtool2 = throw "flvtool2 has been removed."; # added 2020-11-03 foldingathome = fahclient; # added 2020-09-03 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 55a327dab5a5..e6a56903ff89 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8841,8 +8841,6 @@ in fishPlugins = recurseIntoAttrs (callPackage ../shells/fish/plugins { }); - fish-foreign-env = callPackage ../shells/fish/fish-foreign-env { }; - ion = callPackage ../shells/ion { inherit (darwin) Security; }; -- cgit 1.4.1