nina

@june

NixOS is powerful, but it can be a lot. Nina keeps the whole workflow — packages, options, rebuilds, services, remote machines — right at the prompt.

https://nina.asha.software

Zig

v3.4.14 · 229 saves · 10,620 lines · updated 1 week ago

20 files
b80d8ca4cbcb
back to HEAD
a457ce5df838record G-08/G-10 green (update/flakes/build/run/repl/develop) on golden-v24 months agob2791022ccb1fix run double-prefix (pass flake refs as-is) and develop --command (sh -c); add G-08/G-10 test; v3.0.84 months agobed6a267e635record G-05 install/remove/try green (round-trip works) on golden-v24 months ago64ae2f75ae45fix profile remove to use element name not nixpkgs# flake ref; v3.0.74 months ago66158d7cb9d9fix install to prefer exact pname match over first search result; add G-05 install/remove/try test; v3.0.64 months ago83a0d325270crecord G-05/09/11 local groups green on golden-v2; list user-profile finding4 months agoa5729e5778e1fix store path to use nixpkgs#attr instead of current-dir .#attr; v3.0.54 months agoabf1280f1ad9fix service status pager hang (systemctl --no-pager) and add G-05/09/11 local test; v3.0.44 months agod4d5b99bbef8record G-04 search green on golden-v2 (headless fallback + 6GB); search/config/status round complete4 months ago7f3c0e88de47add non-tty plain fallback to nina search (scriptable headless mode); v3.0.3; search test uses </dev/null4 months agocc2e989efbf8G-06/G-07 Run 2 green on golden-v2 (fmt/doctor/diff fixed); add cfgsearch+search tests; record search OOM-at-2GB finding4 months ago1eec3bc4456afix doctor config-syntax check (dry-build) and diff exit propagation; golden enables flakes + nixpkgs-fmt + pinned nixpkgs registry; v3.0.24 months ago751b9272cb67add G-06/G-07 cfgstatus VM test; record baseline findings (fmt/doctor/diff/boot)4 months ago5044329f5c35record G-01/02/03 Run 2 green and nina exit-leak finding in CONTINUITY4 months agoc65779cafae6gen test creates distinct generations via config changes to exercise history/back/go/clean4 months ago7ae2557619eefix generation profile bug (-p system, sudo, activate on go) and clean (delete-generations +N) in exec.zig; v3.0.14 months agod0e45535ef46record G-01/02/03 baseline: apply works, document nina profile (-p) and clean (--delete-older-than) bugs4 months agod52009bf02c1add in-VM test runner and G-01/02/03 generations test; injects fresh nina, captures serial vs ground truth4 months ago07d8306ec610record proven disposable-image loop and nina test-remote rendering finding in CONTINUITY4 months ago5546d34dddbbmake golden-image harness work end-to-end: env-var arg passing, sudo-i for nixos autologin, /dev/vda1 mount, marker-driven serial; golden builds and boots disposably4 months agoa7db23cbf680add test/vm golden-image build harness: configuration.nix, scripted installer, disposable overlay boot4 months agoa336cdb20502before building golden NixOS dev image (test/vm)4 months agod60fc263ea2arecord arch-invariant results and kiln/env feasibility findings in CONTINUITY4 months ago69ed3db2d358remove cross-compiled linux artifact from tree; build to /tmp instead4 months agoc22879cea5cereplace std.c.isatty with libc-free tcgetattr tty check so nina cross-compiles static for linux4 months ago849133ec5facbefore kiln exhaustive test brief — run 1 arch invariants4 months ago1336bd780bbfCONTINUITY.md updated with final state, arch verification results, and Zig 0.16 API discoveries4 months ago2c3d3893f7f1Phase 1-5: foundation, output, api, exec, search TUI, commands — compiles and tests pass on Zig 0.164 months agoedb704e69eb3before nina v3 implementation4 months ago

← newer

details

nina

Nina is a command-line helper for NixOS. Use it to find packages, apply your configuration, roll back a generation, or check another machine over SSH.

nina search ripgrep
nina apply
nina back
nina status --all

It calls the Nix tools you already use and gives common tasks shorter names. Your configuration stays in Nix files. Nina is written in Zig and builds as a single binary with no third-party Zig dependencies; it needs Nix and the relevant system tools to carry out commands.

Install

Nina's system commands are for NixOS. Package and development commands use Nix, which needs the nix-command and flakes experimental features enabled.

Install in your user profile:

nix profile add 'https://kepr.uk/nina/archive/HEAD.tar.gz#nina'

Then run:

nina setup

Setup creates Nina's configuration if it is missing and checks the required Nix features. On NixOS, it offers to add the setting to /etc/nixos/configuration.nix; you must rebuild for it to take effect. If the install command above fails because these features are disabled, enable them in Nix first.

To build from source, you need Zig 0.16:

koh steal kepr.uk/nina
cd nina && zig build -Doptimize=ReleaseFast
sudo cp zig-out/bin/nina /usr/local/bin/nina

You can also download a source archive from releases:

tar xf nina-*.tar.gz && cd nina-*/
zig build -Doptimize=ReleaseFast
sudo cp zig-out/bin/nina /usr/local/bin/nina

nina goodbye uninstalls Nina. Run nina update to check for a newer Nina release. If your system configuration manages Nina, update it through that configuration.

Apply a configuration

nina edit opens configuration.nix in your editor. Check it before applying, or build it without switching:

nina edit
nina check
nina apply --dry
nina apply

Nina also supports flake-based system configurations. Set the machine's config directory to the directory containing your configuration.

If you need to go back, use nina back. To choose a specific generation, find its number with nina history, then run nina go <n>.

Command What it does
nina history Lists system generations
nina back Rolls back one generation
nina go <n> Switches to generation <n>
nina diff Compares generations
nina upgrade Updates Nix inputs or channels and rebuilds
nina clean Removes old system generations and collects garbage

nina clean keeps the number of generations set in your config, five by default. Removing generations means you can no longer roll back to them.

Find and use packages

nina search <q> searches nixpkgs through nix search. In a terminal, results appear in an inline browser. Use the arrow keys to move, Tab for package details, Enter to select a package, and Escape to cancel. When stdin is not a terminal, search prints a plain list.

nina search ripgrep
nina install ripgrep
nina try ripgrep
nina remove ripgrep
nina list

Selecting a package in search or running nina install asks how you want to use it:

  • Install it in your user profile without a system rebuild.
  • Add it through your system configuration: Nina opens the editor at the package list and offers to apply your changes.
  • Try it in a temporary shell without installing it.

Search and installation may need network access to fetch Nix inputs or packages. nina option <q> searches NixOS options.

Home Manager

Nina supports standalone Home Manager and Home Manager integrated into a NixOS configuration. To create a standalone configuration:

nina home init

Add --switch to activate it immediately. Nina chooses a Home Manager branch from your NixOS version and leaves an existing configuration in place.

Command What it does
nina home apply Applies your home configuration
nina home back Rolls back one home generation
nina home history Lists home generations
nina home edit Opens home.nix
nina home check Builds the home configuration without switching
nina home diff Compares the latest two home generations
nina home packages Lists packages in the home generation

When Home Manager is part of your NixOS configuration, nina home apply runs a system rebuild. Home commands operate on the local user; they do not support --on.

Configure Nina

Nina reads ~/.config/nina/config, or $XDG_CONFIG_HOME/nina/config when that environment variable is set.

editor      = hx
generations = 5
confirm     = true
teach       = false
color       = true

[machine]
name    = my-machine
config  = /etc/nixos
local   = true
default = true

Set editor to your preferred editor. generations controls how many system generations cleanup keeps. With teach = true, Nina prints the underlying commands as you work.

Nina disables color when stdout is not a terminal and respects NO_COLOR.

Work on another machine

Add a machine with an SSH host to your config:

[machine]
name    = azula
host    = azula
user    = june
ssh_key = ~/.ssh/id_ed25519

Put --on <name> after the command to select it:

nina apply --on azula
nina service logs ollama -f --on azula
nina status --all

Remote system operations use SSH and the tools on the target machine. nina status --all checks every configured machine. Use nina hello to list them.

Run hooks

Place executable scripts in ~/.config/nina/hooks/ to run before or after these operations:

pre-apply     post-apply
pre-back      post-back
pre-home      post-home
pre-upgrade   post-upgrade

Missing or non-executable hooks are skipped. If a pre-hook fails, Nina shows its last five output lines and asks whether to continue, defaulting to no. A failed post-hook produces a warning after the operation succeeds. Hooks run locally, including when the operation targets a remote machine.

For example, save this as ~/.config/nina/hooks/pre-apply to check for uncommitted changes, then make it executable with chmod +x:

#!/usr/bin/env sh
# ~/.config/nina/hooks/pre-apply
if git -C ~/nixos-config status --porcelain | grep -q .; then
    echo "uncommitted changes - commit before applying"
    exit 1
fi

More commands

Command What it does
nina status Shows machine health
nina doctor Checks for common problems
nina log Shows Nina's operation history
nina service list Lists systemd services
nina service logs <s> Reads a service's journal
nina service start/stop/restart <s> Controls a service
nina flake show Shows flake outputs
nina flake update Updates flake inputs
nina pin <in> <rev> Pins a flake input to a revision
nina unpin <in> Updates a pinned input
nina develop Enters a development shell
nina build Builds a flake output
nina run <p> Runs a package
nina edit --dir Opens the configuration directory
nina fmt Formats the system configuration
nina info Shows system information
nina boot Lists boot entries

Run nina help for the full command list, nina <group> help for a group such as home or service, and nina man [topic] for the built-in manual. nina --version prints the installed version.

Build and test

From the source directory:

zig build
zig build test
zig fmt --check build.zig src/*.zig

System operations need a NixOS host for live testing. The VM test harness describes testing against disposable NixOS images.

Made by Asha Software.

Website · Source · Documentation