mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
parent
e5cf9b15ae
commit
745896c85a
2 changed files with 44 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue