From 254eebd8a0782430dfb0b78bef3b657ad0caed8a Mon Sep 17 00:00:00 2001 From: Nathan Zadoks Date: Sun, 27 Dec 2015 16:36:17 +0100 Subject: [PATCH 1/3] command-not-found: add NIX_AUTO_RUN --- nixos/modules/programs/command-not-found/command-not-found.nix | 2 +- nixos/modules/programs/command-not-found/command-not-found.pl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos/modules/programs/command-not-found/command-not-found.nix b/nixos/modules/programs/command-not-found/command-not-found.nix index 9524d91ea3bc..9d3f61f5ff9b 100644 --- a/nixos/modules/programs/command-not-found/command-not-found.nix +++ b/nixos/modules/programs/command-not-found/command-not-found.nix @@ -16,7 +16,7 @@ let isExecutable = true; inherit (pkgs) perl; perlFlags = concatStrings (map (path: "-I ${path}/lib/perl5/site_perl ") - [ pkgs.perlPackages.DBI pkgs.perlPackages.DBDSQLite ]); + [ pkgs.perlPackages.DBI pkgs.perlPackages.DBDSQLite pkgs.perlPackages.StringShellQuote ]); }; in diff --git a/nixos/modules/programs/command-not-found/command-not-found.pl b/nixos/modules/programs/command-not-found/command-not-found.pl index b233d973a4ab..5bdda26592e6 100644 --- a/nixos/modules/programs/command-not-found/command-not-found.pl +++ b/nixos/modules/programs/command-not-found/command-not-found.pl @@ -3,6 +3,7 @@ use strict; use DBI; use DBD::SQLite; +use String::ShellQuote; use Config; my $program = $ARGV[0]; @@ -31,6 +32,8 @@ the package ‘$package’, which I will now install for you. EOF ; exit 126 if system("nix-env", "-iA", "nixos.$package") == 0; + } elsif ($ENV{"NIX_AUTO_RUN"} // "") { + exec("nix-shell", "-p", $package, "--run", shell_quote("exec", @ARGV)); } else { print STDERR < Date: Sun, 27 Dec 2015 16:36:46 +0100 Subject: [PATCH 2/3] fish: pass all of argv to command-not-found --- pkgs/shells/fish/command-not-found.patch | 13 +++++++++++++ pkgs/shells/fish/default.nix | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 pkgs/shells/fish/command-not-found.patch diff --git a/pkgs/shells/fish/command-not-found.patch b/pkgs/shells/fish/command-not-found.patch new file mode 100644 index 000000000000..aaca001dcb67 --- /dev/null +++ b/pkgs/shells/fish/command-not-found.patch @@ -0,0 +1,13 @@ +diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish +index c3864a8..a12ac4d 100644 +--- a/share/functions/__fish_config_interactive.fish ++++ b/share/functions/__fish_config_interactive.fish +@@ -230,7 +230,7 @@ function __fish_config_interactive -d "Initializations that should be performed + # Check for NixOS handler + else if test -f /run/current-system/sw/bin/command-not-found + function __fish_command_not_found_handler --on-event fish_command_not_found +- /run/current-system/sw/bin/command-not-found $argv[1] ++ /run/current-system/sw/bin/command-not-found $argv + end + # Ubuntu Feisty places this command in the regular path instead + else if type -q -p command-not-found diff --git a/pkgs/shells/fish/default.nix b/pkgs/shells/fish/default.nix index ef3794d5144c..c2fcfa3e7c18 100644 --- a/pkgs/shells/fish/default.nix +++ b/pkgs/shells/fish/default.nix @@ -4,6 +4,8 @@ stdenv.mkDerivation rec { name = "fish-${version}"; version = "2.2.0"; + patches = [ ./command-not-found.patch ]; + src = fetchurl { url = "http://fishshell.com/files/${version}/${name}.tar.gz"; sha256 = "0ympqz7llmf0hafxwglykplw6j5cz82yhlrw50lw4bnf2kykjqx7"; From e60c4995fdea8ab86115149f89fca84275480fb7 Mon Sep 17 00:00:00 2001 From: Arda Xi Date: Mon, 28 Dec 2015 14:49:53 +0100 Subject: [PATCH 3/3] command-not-found: pass all of argv to helper --- .../modules/programs/command-not-found/command-not-found.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/programs/command-not-found/command-not-found.nix b/nixos/modules/programs/command-not-found/command-not-found.nix index 9d3f61f5ff9b..9741aa7ca539 100644 --- a/nixos/modules/programs/command-not-found/command-not-found.nix +++ b/nixos/modules/programs/command-not-found/command-not-found.nix @@ -30,7 +30,7 @@ in local p=/run/current-system/sw/bin/command-not-found if [ -x $p -a -f /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite ]; then # Run the helper program. - $p "$1" + $p "$@" # Retry the command if we just installed it. if [ $? = 126 ]; then "$@" @@ -51,7 +51,7 @@ in local p=/run/current-system/sw/bin/command-not-found if [ -x $p -a -f /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite ]; then # Run the helper program. - $p "$1" + $p "$@" # Retry the command if we just installed it. if [ $? = 126 ]; then