Modern computing is silly

nix

Bro you are writing to stderr just to say this to me. How hard would it be… Why?

No not really, nix-shell automatically fetching man when required would squarely fall into tbe category of “surprising behaviors”.

Modern computers should do exactly as they’re told, not attempt to figure things out.

5 Likes

True, but it’s not really what I meant :sweat_smile:

It already has stdout, and it knows how to use it.

Ah, sorry, i assumed you meany that :slight_smile:.

The reason not to use stdout is because stdout should be reserved for actual program output.

I am not 100% sure how nix-shell works, ill use nix shell as an example instead.

Doing:

nix shell nixpkgs#jg --command 'jq'

Runs jq, if nix were to output diagnostics on stdout, the output would conflate with actual output from jq.

That is why in general logging, including error logging goes to stderr. Special casing the missing man output to go out through stdout would not only be confusing but also difficult.

3 Likes

That is also why a POSIX | (pipe) operates on stdout. You can make it operate on both |& or a specific FD |&2 (i hope i got the syntax right) but both of those are bash-isms.

It only explains the problem for nix-shell though, and even then, if printing to stdout is unacceptable, it could just dump help to stderr. Not perfect but at least works.

Funny enough, nix <subcommand> --help works as expected (-ish, it still opens a pager), even for shell :melting_face:

Ah well the --help flag needs man because the only help format for nix-shell is a manual page. Dumping a man page as is onto stderr would be unreadable

You mean rst? This should be fairly readable, not far from markdown. Is better than nothing.

I see the problem if it’s troff

p.s. anyway, thanks for your input.

I think its troff yeah. In any case, youre again trying to special case it :slight_smile: not a good idea imo

In fairness, how hard could it be to just render a simpler version, perhaps with templating, instead? C codebase not withstanding, though perhaps this is easier to do in lix.

OTOH, expecting man to be installed on a system where you call interactive flags like --help is also not a high bar.

Overall, of all the UI/UX issues nix has this is probably not the worst one. Submit a patch?

4 Likes

Manpages are also available at nix.dev, e.g. nix-shell - Nix 2.34.8 Reference Manual

I agree that’s it’s stupid that nix isn’t wrapped with man or something but here we are.

3 Likes

Maybe I am misunderstanding (and please tell me if I am), but it seems kind of weird to me that requiring nix-shell to depend on a whole other package for the --help flag is somehow more acceptable than just printing some helpful information in the terminal if man isn’t available?

Off the top of my head, I can’t think of any other CLI programs that require man to be installed to print their help information. I can think of CLI programs that don’t have any sort of --help flag at all, but the vast majority of programs have expected --help flags that output some instructions for using the program. Is there some history or context for why nix-shell does not work the same way?

1 Like

I’d say that redirecting --help to a man page is surprising behavior and most people expect a usage listing instead.

8 Likes

I mean sure, i dont disagree, but including man by wrapping nix is more suprising imo

It’s pretty common. E.g. systemctl & friends require a pager, i.e., less.

Many modern, interactive-oriented CLI utilities require man or less to handle nice output; rewriting the curses logic of those utilities just isn’t worth the effort. You typically don’t notice, because those utilities are preinstalled 99.9999% of the time and they’re used transparently.

It’s less common for those applications to fully refuse output if those utilities are missing, but not unheard of.


I’m kind of in support this design choice, to be honest. Why maintain a bunch of edge case output code just in case someone goes all “unbloat” and deletes man to save a few kilobytes on a headless server and then changes their mind about wanting it to be headless?

If you wanna do “unbloat” and headless, then commit properly and use your dev machine’s terminal, push with nix-copy-closure and nixos-rebuild --target-host. Nix covers these use cases pretty well. You should never run into this edge case under idiomatic use, and even if you do, man is just a nix-shell away.

I’d probably think twice about merging a patch to solve this to cppnix if I maintained it. Maybe think less hard about it for lix if it used rust and some well-maintained and highly used crate that mostly farms off the maintenance burden.

I’d also argue wrapping nix so that man is in its closure should probably be skipped for a headless profile. This is squarely within the user’s choices domain, I’m with @hexa (wrong ping, sorry) @MagicRB on this.

For non-headless profiles we should definitely be wrapping nix with man though.

2 Likes