juspay / nix-health

REPO MOVED https://github.com/juspay/omnix/tree/main/crates/nix_health
https://github.com/juspay/omnix/tree/main/crates/nix_rs
28 stars 2 forks source link

Run nix-health in devShell hook #14

Closed srid closed 1 month ago

srid commented 2 months ago

The idea is to have nix-health --quiet --giant-warning run as part of devShell's shellHook such as to make it difficult for the user to miss errors from nix-health (especially as shellHook cannot "interrupt" the devShell) and yet make nix-health quiet in cases it succeeds.

srid commented 1 month ago

In conjunction with https://github.com/juspay/nix-dev-home/pull/39

and:

image

we get:

image

I guess the only thing left to do is ... that giant warning? We could possibly use figlet for that:

❯ echo 'See errors above' | , figlet
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
 ____                                                   _                    
/ ___|  ___  ___    ___ _ __ _ __ ___  _ __ ___    __ _| |__   _____   _____ 
\___ \ / _ \/ _ \  / _ \ '__| '__/ _ \| '__/ __|  / _` | '_ \ / _ \ \ / / _ \
 ___) |  __/  __/ |  __/ |  | | | (_) | |  \__ \ | (_| | |_) | (_) \ V /  __/
|____/ \___|\___|  \___|_|  |_|  \___/|_|  |___/  \__,_|_.__/ \___/ \_/ \___|
srid commented 1 month ago

Or, with:

devShells.default = pkgs.mkShell {
  shellHook = ''
    trap "${lib.getExe pkgs.toilet} NIX SHELL FAILED --filter gay -f smmono9" ERR

    ${lib.getExe pkgs.nix-health} --quiet .
  '';
}

we get:

image
srid commented 1 month ago

https://github.com/juspay/nix-health?tab=readme-ov-file#adding-devshell-check

@shivaraj-bh Is this good enough, or should we improve the ergonomics further?

EDIT: n/m - #18 should be good enough; see example https://github.com/srid/emanote/commit/fcf67dca2e7a95e4c5ac187586dc1e92dea530cf