Rust CoreUtils replacement

This was at the top of HN just now:

It seems to me that it would be straightforward to override coreutils in NixPkgs and see what breaks, right?

(this is one of those times where I get an idea and I really should be working on something else, so I’ll leave it at this post)

13 Likes

I think the biggest struggle will be to bootstrap rust without causing an infinit recursion.

You certainly will. You will to have an stdenv compiled without change, and then an stdenv with patched coreutils. I’ve made some stuff about this idea:

{ nixpkgs ? <nixpkgs>}:

let
    unpatched_pkgs = import <nixpkgs> {};

    patched_coreutils = (unpatched_pkgs.uutils-coreutils.overrideAttrs (old: {
        /*prePatch = ''
            export buildPhase=
        '';*/
        #postBuild = "make $makeFlags"; #this seem useless
        # can we just skip the rust build phase ?
        postInstall = ''
            make install $makeFlags
        '';
    })).override {prefix="";};

    patched_stdenv = unpatched_pkgs.stdenv.override (old: {
        initialPath = [
            patched_coreutils
            unpatched_pkgs.findutils
            unpatched_pkgs.diffutils
            unpatched_pkgs.gnused
            unpatched_pkgs.gnugrep
            unpatched_pkgs.gawk
            unpatched_pkgs.gnutar
            unpatched_pkgs.gzip
            unpatched_pkgs.bzip2.bin
            unpatched_pkgs.gnumake
            unpatched_pkgs.bash
            unpatched_pkgs.patch
            unpatched_pkgs.xz.bin
        ];
    });


    pkgs = import nixpkgs {
        overlays = [
            (self: super: {
                coreutils = patched_coreutils;
                stdenv = patched_stdenv;
            })
        ];
    };
in {
    bash = unpatched_pkgs.bash.override { stdenv = patched_stdenv; };
    #uutils = patched_coreutils;
}

I haven’t yet tried (as I was offline when I wrote this). I also need to rewrite the uutils package in nixpkgs too (but I overwrited). As it only have the uutils […] binary in the nixpkgs version (probably a bug after an automatic upgrade, as it have the flag for this). Or a change in the buildRustCrate.

1 Like

I did a coreutils reference free stdenv before I saw marius answer: stdenv: add uutils-coreutils stdenv by SuperSandro2000 · Pull Request #116274 · NixOS/nixpkgs · GitHub

5 Likes