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
Find a file
2025-04-30 00:57:12 -04:00
functions Fix argument passing in __yay_rebuild function for host flag 2025-04-30 00:57:12 -04:00
pkgs Updates host switch and completions paths 2025-04-29 23:16:09 -04:00
share/fish/completions Add function loading mechanism to ensure required functions are available 2025-04-30 00:54:50 -04:00
flake.nix Initial Commit with possibly working flake 2025-04-27 15:08:23 -04:00
readme.md New command features for try and update, and yay_run improvement 2025-04-30 00:43:40 -04:00

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:

  1. Cleans using nh clean all (with and without sudo)
  2. Runs nix-collect-garbage --delete-old (with and without sudo)
  3. Executes nix-store --gc (with and without sudo)
  4. 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:

  1. Creates a temporary fish script
  2. Sets up the fish function path to include the installed functions
  3. Sources the main yay.fish file
  4. Passes all command-line arguments to the appropriate fish function
  5. Cleans up after execution

All commands and options have completions making the tool easy to use interactively.

License

MIT