nix-community / nix-on-droid

Nix-enabled environment for your Android device. [maintainers=@t184256,@Gerschtli]
https://nix-on-droid.unboiled.info
MIT License
1.25k stars 69 forks source link

TeXLive appears to require sed at runtime #152

Closed alexshpilkin closed 2 years ago

alexshpilkin commented 2 years ago

The TeXLive 2021 distribution (e.g. the texlive.combined.scheme-medium Nixpkgs package) in Nix-on-Droid seems to be missing a dependency on sed, even though it installs fine without it. The culprit is the mktextfm (make TeX font metrics) script, which is invoked every time a previously unused (font, size) combination is requested on the system, and seems to require sed to run (I don't know if it has to be GNU sed or if any POSIX sed will do).

I suspect this is a problem with upstream Nixpkgs, but I'm filing it here for now just in case there is some sort of implicit "base system" assumption in Nixpkgs / NixOS that Nix-on-Droid violates.

t184256 commented 2 years ago

Can't say I'm aware of the "base system" assumptions of NixOS either. Please point us at them if you find them; though it doesn't necessarily mean we'll follow them by default though. E.g., preinstalling stdenv is something we avoid on purpose.

The missing dependency does sound like a packaging bug to me.

Gerschtli commented 2 years ago

No package should rely on any base system environment. That is the whole idea of nix packaging. So this should be reproducable in every other (pure) environment and therefore a bug in nixpkgs :)

alexshpilkin commented 2 years ago

@Gerschtli

No package should rely on any base system environment. That is the whole idea of nix packaging.

Yeah, that sounded weird to me too, but it’s a fairly common practice in conventional distros and I know next to nothing about the internal organization of Nixpkgs & friends, so I decided to hedge a bit in case Nix-on-Droid does actually do something atypical. I honestly don’t know if it is possible to make a normal NixOS install that wouldn’t have sed (or cp, or ...) in $PATH, and if it is, how.

alexshpilkin commented 2 years ago

OK, the problem set is out, I can now try to make a less lazy reproduction for this.

... But it turns out to be trickier than I thought: it’s straightforward to get mktextfm to be invoked by doing what I was doing—typesetting documents in Cyrillic—but that requires a fairly extensive TeXLive installation. I must admit I can’t actually get it to run on e.g. a ‘basic’ installation with a small English-language test document, probably because the default (Latin-only) Computer Modern fonts come with metrics already included.

Still, if you find the combined texlive-whatever package inside the Nix store and look in share/texmf/scripts/texlive/mktexmf, there are a couple of invocations of sed in the very first lines of the script (that accomplish the equivalent of basename and dirname or a shell substitution like ${0##*/}, but it is what it is).

I’ll try to take this to the Nixpkgs people and see what they say.

t184256 commented 2 years ago

typesetting documents in Cyrillic—but that requires a fairly extensive TeXLive installation

True. I used to configure elaborate environments with texlive.combine by trial and error, but then decided life's too short and switched to just pulling enormous -scheme based ones =)

Gerschtli commented 2 years ago

@alexshpilkin You are right, conventional distros rely on such a base configuration, which is a problem that nix tries to solve. I never tested it, but is should be possible to remove every package from environment.systemPackages and the user installed ones except for the basic nix-* packages and it should run perfectly fine. If not, then this should be filed as a bug. Sometimes it is just hard to find these runtime dependencies if you do not run everything in a pure mode :)