• Replaces raw eval with a safer fish shell command execution • Improves try commands with '--' separator for running one-shot commands • Adds support for updating a specific flake input via flag or positional argument • Updates documentation and completions for consistency and clarity
4.8 KiB
Yay.nix
Yay.nix (Yet another Yay) is a simple wrapper around useful commands I use all the time and can't be bothered to keep typing. I also just miss writing yay in terminal.
Overview
Yay.nix provides simple, user-friendly commands for common Nix operations like rebuilding your flake config, updating flakes, garbage collection, and more. It includes fish shell completions for all commands and options, making it faster and easier to work with Nix.
Installation
As a Flake
Add to your flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
yay-nix = {
url = "github:Tophc7/yay.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, yay-nix, ... }: {
# For NixOS system configuration
nixosConfigurations.<yourhostname> = nixpkgs.lib.nixosSystem {
# ...
modules = [
yay-nix.nixosModules.default
# ...
];
};
};
}
With Home Manager
{
imports = [
inputs.yay-nix.homeManagerModules.default
];
}
Try in shell
#create shell with yay
nix shell github:Tophc7/yay.nix
## run any yay command
yay try fastfetch -- fastfetch --config examples/24
yay garbage
Commands
rebuild
Rebuild your NixOS configuration.
It will look for a flake in this pattern: -p <PATH> > $FLAKE > ./
yay rebuild [OPTIONS]
Options:
-p, --path PATH
: Path to the Nix configuration (overrides FLAKE env var)-H, --host HOST
: Hostname to build for (default: current hostname)-t, --trace
: Enable trace output-h, --help
: Show help message
update
Update flake inputs. You can update all inputs or specify a single input to update.
yay update [OPTIONS] [INPUT]
Options:
-p, --path PATH
: Path to the Nix configuration (overrides FLAKE)-i, --input INPUT
: Name of the specific input to update (alternative to positional argument)-h, --help
: Show help message
Examples:
# Update all inputs
yay update
# Update only the 'nixpkgs' input
yay update nixpkgs
# Update 'nixpkgs' using the flag
yay update -i nixpkgs
garbage
Clean up the Nix store and home-manager backups. Super overkill don't come for me if something goes wrong. Regardless I use it all the time.
yay garbage
This command:
- Cleans using
nh clean all
(with and without sudo) - Runs
nix-collect-garbage --delete-old
(with and without sudo) - Executes
nix-store --gc
(with and without sudo) - Removes home-manager backup files
try
Create a temporary shell with specified packages. You can either drop into an interactive shell or run a command directly within the environment using --
.
yay try PACKAGE [PACKAGE...] [-- COMMAND [ARGS...]]
Examples:
# Enter an interactive shell with fastfetch and cowsay available
yay try fastfetch cowsay
# Run 'fastfetch' directly using the packages in the temporary shell
yay try fastfetch -- fastfetch
# Run 'cowsay moo' directly using the cowsay package
yay try cowsay -- cowsay moo
tar
Create compressed archives with various compression methods.
yay tar [OPTIONS] INPUT_PATH [OUTPUT_PATH]
Options:
-c, --compression TYPE
: Compression type (default: zstd)-l, --level N
: Compression level where applicable-o, --output PATH
: Output file path-t, --threads N
: Number of threads to use where supported-v, --verbose
: Enable verbose output-h, --help
: Show help message
Supported compression types:
7zip
: .7z (levels: 0-9, default 5)bzip2
: .tar.bz2 (levels: 1-9, default 9)bzip3
: .tar.bz3 (block size in MiB: 1-511, default 16)gzip
: .tar.gz (levels: 1-9, default 6)tar
: .tar (no compression)zstd
: .tar.zst (levels: 1-19, default 3)
untar
Extract various archive formats.
yay untar [OPTIONS] ARCHIVE [OUTPUT_DIR]
Options:
-o, --output DIR
: Output directory-v, --verbose
: Enable verbose output-h, --help
: Show help message
Supported archive formats (auto-detected from extension):
.7z
,.tar.7z
(7-Zip).tar.bz2
,.tb2
,.tbz
,.tbz2
,.tz2
(bzip2).tar.bz3
(bzip3).tar.gz
,.tgz
(gzip).rar
(RAR).tar
(uncompressed tar).tar.zst
,.tzst
(zstd)
more?
If theres a command you think would be useful to add let me know, I might agree.
Technical Details
Yay.nix is implemented as a collection of fish functions that are installed into your system's fish function path. The main yay
command is a bash script that:
- Creates a temporary fish script
- Sets up the fish function path to include the installed functions
- Sources the main yay.fish file
- Passes all command-line arguments to the appropriate fish function
- Cleans up after execution
All commands and options have completions making the tool easy to use interactively.
License
MIT