How to use uutils-coreutils instead of the builtin coreutils?

Well obviously, if you set lib.hiPrio, uutils will get chosen, which was my point. Otherwise it’s pure luck.

But how does one set lib.hiPrio?

1 Like

call lib.hiPro on the desired derivation before installing it.

  environment.systemPackages = [
    (lib.hiPrio pkgs.uutils-coreutils-noprefix)
  ];
5 Likes

I also tried system.replaceDependencies but that’s failing during the build.

Ubuntu is now also switching to uutils-coreutils. :wink:
See Carefully But Purposefully Oxidising Ubuntu - Project Discussion - Ubuntu Community Hub.

2 Likes

I don’t dare to replace it on all systems, I just wanted to try it on a few desktop systems. Currently I use some shell aliases to just use the new tooling in the terminal.

But I guess Ubuntu trying to use it is a good thing, because they will see that a few issues will be fixed.

Hi,

You can simple do that :

environment.systemPackages = with pkgs; [
(pkgs.uutils-coreutils.override { prefix = ""; })
];

Best Regards

That’s what

already does :slight_smile: And my answer handles the conflicts for identically named binaries.

2 Likes

There does not exist a uutils-findutils-noprefix package nor a uutils-diffutils-noprefix package in nixpkgs

https://search.nixos.org/packages?show=uutils-

But would they also require their prefix to be stripped?

If yes: do you think a uutils-findutils-noprefix package and a uutils-diffutils-noprefix package should be added to nixpkgs? otherwise, what would be the snippets to add in one’s nix configuration?

I also just created the documentation page for Uutils on the official NixOS Wiki

Please feel free to contribute to it

3 Likes

hmm.

while pkgs.uutils-coreutils-noprefix and pkgs.uutils-findutils could replace (again, with hiPrio) the original GNU coreutils, however, the pkgs.uutils-diffutils cannot.

the only package (command) pkgs.uutils-diffutils provides is literally diffutils, and not the diff, cmp, diff3, sdiff separately.

correct me if im wrong?

:frog:

It’s a multicall binary. It would probably be a nice PR to add the relevant symlinks to the derivation.

3 Likes

No because there’s no prefix to strip for uutils-findutils.

$ tree $(nix build nixpkgs#uutils-findutils --print-out-paths --no-link)
/nix/store/0x5pvgj0xj5b8fsanlflg0lzhjabfk0z-uutils-findutils-0.8.0
└── bin
    ├── find
    └── xargs

and uutils-diffutils was discussed above.

1 Like

Understood, thanks


About:

It also seems to me that using system.replaceDependencies instead of lib.hiPrio would indeed be the best if doable

Do anyone know why it is failing during build or if there is any chance of making it work?

Share your code and the error.

The following seems to work:

system.replaceDependencies.replacements = [
  {
    # system
    oldDependency = pkgs.coreutils-full;
    newDependency = pkgs.symlinkJoin {
      # Make the name length match so it builds
      name = "new-rust-coreutils";
      paths = [pkgs.uutils-coreutils-noprefix];
    };
  }
  {
    # applications
    oldDependency = pkgs.coreutils;
    newDependency = pkgs.symlinkJoin {
      # Make the name length match so it builds
      name = "new-coreutils";
      paths = [pkgs.uutils-coreutils-noprefix];
    };
  }
];

This is quite hacky as it adds an additional layer of symlinks, but it works.
Also it’s likely to break on update.

1 Like

FYI lib.hiPrio is no longer needed on unstable as of a couple weeks ago; some changes were made to lower the priority of the base set of packages (see the definitions for environment.corePackages).

Sorry for replying late, I didn’t see this one


Since:

I assumed it didn’t work and haven’t tried myself;

It just intuitively came to me that:

I have taken the time to write a declarative version of your solution, this reads the length of the source packages version number and creates a string of matching length for the new uutils.

{ pkgs, ... }:
let
  coreutils-full-name = "coreuutils-full-" + builtins.concatStringsSep ""
    (builtins.genList (_: "v") ((builtins.stringLength pkgs.coreutils-full.version) - 1));

  coreutils-name = "coreuutils-" + builtins.concatStringsSep ""
    (builtins.genList (_: "v") ((builtins.stringLength pkgs.coreutils.version) - 1));

  findutils-name = "finduutils-" + builtins.concatStringsSep ""
    (builtins.genList (_: "v") ((builtins.stringLength pkgs.findutils.version) - 1));

  diffutils-name = "diffuutils-" + builtins.concatStringsSep ""
    (builtins.genList (_: "v") ((builtins.stringLength pkgs.diffutils.version) - 1));
in
{
  system.replaceDependencies.replacements = [
    # coreutils
    {
      # system
      oldDependency = pkgs.coreutils-full;
      newDependency = pkgs.symlinkJoin {
        # Make the name length match so it builds
        name = coreutils-full-name;
        paths = [pkgs.uutils-coreutils-noprefix];
      };
    }
    {
      # applications
      oldDependency = pkgs.coreutils;
      newDependency = pkgs.symlinkJoin {
        # Make the name length match so it builds
        name = coreutils-name;
        paths = [pkgs.uutils-coreutils-noprefix];
      };
    }
    # findutils
    {
      # applications
      oldDependency = pkgs.findutils;
      newDependency = pkgs.symlinkJoin {
        # Make the name length match so it builds
        name = findutils-name;
        paths = [pkgs.uutils-findutils];
      };
    }
    # diffutils
    {
      # applications
      oldDependency = pkgs.diffutils;
      newDependency = pkgs.symlinkJoin {
        # Make the name length match so it builds
        name = diffutils-name;
        paths = [pkgs.uutils-diffutils];
      };
    }
  ];
}