mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-10-26 13:55:28 +03:00
parent
e5cf9b15ae
commit
745896c85a
26
modules/nix/README.md
Normal file
26
modules/nix/README.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Nix
|
||||
|
||||
Commands for working with [nix](https://nixos.org/).
|
||||
|
||||
### ns
|
||||
Shorthand search (`nix search nixpkgs ...`) with much nicer output.
|
||||
```shell
|
||||
❯ > nix search nixpkgs diesel
|
||||
* legacyPackages.x86_64-linux.diesel-cli (2.1.0)
|
||||
Database tool for working with Rust projects that use Diesel
|
||||
|
||||
* legacyPackages.x86_64-linux.diesel-cli-ext (0.3.13)
|
||||
Provides different tools for projects using the diesel_cli
|
||||
```
|
||||
```shell
|
||||
❯ > ns diesel
|
||||
╭───┬────────────────┬──────────────────────────────────────────────────────────────┬─────────╮
|
||||
│ # │ package │ description │ version │
|
||||
├───┼────────────────┼──────────────────────────────────────────────────────────────┼─────────┤
|
||||
│ 0 │ diesel-cli │ Database tool for working with Rust projects that use Diesel │ 2.1.0 │
|
||||
│ 1 │ diesel-cli-ext │ Provides different tools for projects using the diesel_cli │ 0.3.13 │
|
||||
├───┼────────────────┼──────────────────────────────────────────────────────────────┼─────────┤
|
||||
│ # │ package │ description │ version │
|
||||
╰───┴────────────────┴──────────────────────────────────────────────────────────────┴─────────╯
|
||||
```
|
||||
|
18
modules/nix/nix.nu
Normal file
18
modules/nix/nix.nu
Normal file
@ -0,0 +1,18 @@
|
||||
# Search nixpkgs and provide table output
|
||||
export def ns [
|
||||
term: string # Search target.
|
||||
] {
|
||||
|
||||
let info = (
|
||||
sysctl -n kernel.arch kernel.ostype
|
||||
| lines
|
||||
| {arch: ($in.0|str downcase), ostype: ($in.1|str downcase)}
|
||||
)
|
||||
|
||||
nix search --json nixpkgs $term
|
||||
| from json
|
||||
| transpose package description
|
||||
| flatten
|
||||
| select package description version
|
||||
| update package {|row| $row.package | str replace $"legacyPackages.($info.arch)-($info.ostype)." ""}
|
||||
}
|
Loading…
Reference in New Issue
Block a user