Nx a wrapper for nix, request for comments

Hi all!
I’m a little new to NixOS, long time linux user, I got my first linux running with the mach microkernel on a powermacintosh 6100, I was there when gentoo lost their wiki. That was when I moved to arch linux. Anyhow, I followed Wil T’s tutorials and kind of wrote my script before finishing his tutorial. I’ve kind of diverged from him entirely at this point and have my own opinionated structure of my dotfiles, of which I’m going to call ~/.nx from here on out. Anyhow my tool is called nx because it is one letter less than nix. It is here I’d like comments etc from the community.

As an example

nix --extra-experimental-features "nix-command flakes" search nixpkgs gimp

is shortened to:

nx s gimp

➜ nx
nx - one less letter to type than nix
nx is an opinionated tool I use to manage my NixOS installations.
by default it uses a directory in your home '~/.nx'
apply-colmena:          nx ac GROUP
apply-system:           nx as
git-commit-am:          nx am
apply-user:             nx au
full-auto:              nx auto
edit-config:            nx ec
edit-flake:             nx ef
edit-group-flake:       nx ef GROUP
edit-user-config:       nx eu
garbage-collector:      nx gc
optimize+gc:            nx o
search PACKAGE:         nx s PACKAGE
update-system:          nx us
update-user:            nx uu

It looks similar to an Emacs mode map, if someone asks me.

1 Like

I was thinking more of how the kubectl plugin works for oh-my-zsh, but I’m certain you, rightly, point out the true inspirations for that in itself. In any case, I chose to write this in plain bourne shell so it should work on a very minimal setup without installing fancy shells, or entire operating systems (in the case of emacs :stuck_out_tongue: ).

There’s another tool called nx that does pretty much the same thing as nix.

Don’t think it’ll be much of an issue but you should be aware.

1 Like

I solve this problem using fish shell abbreviations.

1 Like

Do you have a link? I searched the repos for anything that has \.nx, but did not find anything.

➜ nx s nx|grep -P '\.nx' 

Any interesting abbreviations you use that I am lacking? Or have you published them anywhere?

Updated infrequently: nix-configs/home-manager/shell.nix at main - nat-418/nix-configs - Codeberg.org

If you need something to take an argument or whatever more complex than a simple abbreviation you can easily write a fish shell function too.

There is a widespread javascript build system called nx that offers a command line normally installed via a js package manager (e.g. npm) and more often than not is then put in the PATH, like shown in the tutorials