-
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathcommand-not-found.nu
More file actions
40 lines (40 loc) · 1.16 KB
/
command-not-found.nu
File metadata and controls
40 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{ |cmd_name|
let install = { |pkgs|
$pkgs | each {|pkg| $" nix shell nixpkgs#($pkg)" }
}
let run_once = { |pkgs|
$pkgs | each {|pkg| $" nix shell nixpkgs#($pkg) --command '($cmd_name) ...'" }
}
let single_pkg = { |pkg|
let lines = [
$"The program '($cmd_name)' is currently not installed."
""
"You can install it by typing:"
(do $install [$pkg] | get 0)
""
"Or run it once with:"
(do $run_once [$pkg] | get 0)
]
$lines | str join "\n"
}
let multiple_pkgs = { |pkgs|
let lines = [
$"The program '($cmd_name)' is currently not installed. It is provided by several packages."
""
"You can install it by typing one of the following:"
(do $install $pkgs | str join "\n")
""
"Or run it once with:"
(do $run_once $pkgs | str join "\n")
]
$lines | str join "\n"
}
let pkgs = (@out@/bin/nix-locate --minimal --no-group --type x --type s --whole-name --at-root $"/bin/($cmd_name)" | lines)
let len = ($pkgs | length)
let ret = match $len {
0 => null,
1 => (do $single_pkg ($pkgs | get 0)),
_ => (do $multiple_pkgs $pkgs),
}
return $ret
}