Minimal nix-shell

Thank you @siraben for the help here.


Wonder how that compares to this

I’ve seen that you are working on a stdenv-less minimal shell. But to add to the blog post linked above, getting rid of glibc is easy (though pretty much any other package you include will again pull it in).

Note this example uses nixpkgs.pkgsCross.musl64.busybox for convenience, but this builds a full gcc-cross for musl64 (not available in the binary caches).
For proper use one would like want to introduce sth. like nixpkgs.busybox-musl or maybe a unified derivation for busybox and busybox-sandbox-shell so save some more bits.

Nevertheless, this comes in at only 5MB:

nix path-info --closure-size --human-readable $(nix-build --no-out-link -A inputDerivation minimal-shell.nix)
/nix/store/wvz9kyyw6n1k3jwk1kk59if1c46g8zqf-minimal-shell	   5.0M


  nixpkgs = import <nixpkgs> {};
  stdenvMinimal = nixpkgs.stdenvNoCC.override {
    cc = null;
    preHook = "";
    allowedRequisites = null;
    initialPath = [ nixpkgs.pkgsCross.musl64.busybox ];  # replace coreutils
    shell = "${nixpkgs.busybox-sandbox-shell}/bin/ash";  # replace bash
    extraNativeBuildInputs = [ ];
  minimalMkShell = nixpkgs.mkShell.override {
    stdenv = stdenvMinimal;
in minimalMkShell {
  name = "minimal-shell";
  buildInputs = [ ];
  shellHook = ''