Compare commits

...

2 Commits
main ... nom

Author SHA1 Message Date
31f2f445f3 justfile: fix nom use condition.
turns out just will plumb the stdout of its running processes, so we detect ttys on stderr instead
2025-05-31 20:43:16 +02:00
bce1f0e912 shell.nix: wrap nixos-rebuild with nix-output-monitor
\#nix-output-monitor-and-chill

nom is only used if the output is a tty, and I provide a escape hatch in the form of NIX_NO_NOM=1.
This solution sidesteps issues like `sudo nixos-rebuild ... |& nom` capturing the sudo password prompt.
2025-05-31 19:45:05 +02:00
2 changed files with 14 additions and 2 deletions

@ -1,6 +1,6 @@
set positional-arguments # makes variables accesible as $1 $2 $@
export GUM_FILTER_HEIGHT := "15"
nom := `if [[ -t 1 ]] && command -v nom >/dev/null; then echo nom; else echo nix; fi`
nom := `if [[ -t 2 ]] && command -v nom >/dev/null; then echo nom; else echo nix; fi`
nix_eval_opts := "--log-format raw --option warn-dirty false"
@_default:
@ -26,7 +26,7 @@ run-vm machine=`just _a_machine` *_:
| xargs -d'\n' nix flake update "$@"
@repl $machine=`just _a_machine` *_:
set -v; nixos-rebuild --flake .#"$machine" repl "${@:2}"
set -v; NIX_NO_NOM=1 nixos-rebuild --flake .#"$machine" repl "${@:2}"
@eval $machine=`just _a_machine` $attrpath="system.build.toplevel.outPath" *_:
set -v; nix eval {{nix_eval_opts}} ".#nixosConfigurations.\"$machine\".config.$attrpath" --show-trace "${@:3}"

@ -1,6 +1,18 @@
{ pkgs ? import <nixpkgs> {} }:
let
nixos-rebuild-nom = pkgs.writeScriptBin "nixos-rebuild" ''
if [[ -t 1 && -z "''${NIX_NO_NOM-}" ]]; then
exec ${pkgs.lib.getExe pkgs.nixos-rebuild} -L "$@" |& ${pkgs.lib.getExe pkgs.nix-output-monitor}
else
exec ${pkgs.lib.getExe pkgs.nixos-rebuild} -L "$@"
fi
'';
in
pkgs.mkShellNoCC {
packages = with pkgs; [
nixos-rebuild-nom
just
jq
gum