tty.is_

Using NixOS? Use comma already!

Okay, so we all know about one of Nix/NixOS's superpowers, nix-shell. It's pretty great. You have a one-off command that you want to run, but you just don't have it installed. Sure, you can do a nix-env -iA coolCommand or add it to your environment.systemPackages… but what if you just want to try a new program out, or don't think you'll use it more than once?

nix-shell is here to save the day

You can use nix-shell to drop you into a temporary environment containing the package you want to poke around with.

nix-shell -p lolcat
nix-shell-lolcat.png
Figure 1: Screenshot of nix-shell in use

Neat, huh? When you exit the nix-shell environment, any additional packages you brought in will no longer be available, and they'll be removed from your drive the next time garbage collection runs.

It's kind of a pain, though, that you have to drop into this new shell and then have to run your command, and then have to exit again… especially when all you want to do is drive-by execute a program.

If only there were a better way

Enter comma. It's easy to set up, just add this to your system's flake and do your little nixos-rebuild happy dance.

modules = [
  nix-index-database.nixosModules.nix-index
  { programs.nix-index-database.comma.enable = true; }
];

Now witness the power of comma.

Old and boring

nix-shell -p lolcat
ls -l | lolcat
exit

So fresh and so clean

ls -l | , lolcat
comma-lolcat.png
Figure 2: Screenshot of , in use