Jump to content

Uutils: Difference between revisions

From NixOS Wiki
Malix (talk | contribs)
m Usage: header name
No edit summary
Line 14: Line 14:
<small>For details, see [https://github.com/uutils/coreutils/blob/main/docs/src/extensions.md Uutils Coreutils - Extensions]</small>
<small>For details, see [https://github.com/uutils/coreutils/blob/main/docs/src/extensions.md Uutils Coreutils - Extensions]</small>


=== Installation ===
[https://search.nixos.org/packages?show=uutils-diffutils Nixpkgs - <code>uutils-coreutils</code>]
In your configuration file, add the [https://search.nixos.org/packages?show=uutils-coreutils-noprefix <code>uutils-coreutils-noprefix</code>] package in <code>environment.systemsPackages</code>, and give it a high priority in order to avoid potential conflicts with [https://search.nixos.org/packages?show=coreutils-full <code>coreutils-full</code>]
 
{{File|3={ pkgs, ... }:
{
  environment.systemPackages = with pkgs; [
    (lib.hiPrio pkgs.uutils-coreutils-noprefix) # `lib.hiPrio` is used to avoid potential conflict with `coreutils-full` (also see https://discourse.nixos.org/t/how-to-use-uutils-coreutils-instead-of-the-builtin-coreutils/8904/15?u=malix)
  ];
}|name=/etc/nixos/configuration.nix|lang=nix}}
<small>If you want a prefixed package for some reason, use [https://search.nixos.org/packages?show=uutils-coreutils <code>uutils-coreutils</code>] instead</small>
<small>If you want a prefixed package for some reason, use [https://search.nixos.org/packages?show=uutils-coreutils <code>uutils-coreutils</code>] instead</small>
{{Note|1=This will '''not''' replace [https://search.nixos.org/packages?show=coreutils-full the <code>coreutils-full</code> package], only install it and give it higher priority
Using [https://search.nixos.org/options?show=system.replaceDependencies <code>system.replaceDependencies</code>] instead of [https://search.nixos.org/options?show=environment.systemPackages <code>environment.systemPackages</code>] seems to be a better approach, but it has not been successful yet
<small>For details, see [https://discourse.nixos.org/t/how-to-use-uutils-coreutils-instead-of-the-builtin-coreutils/8904/36?u=malix NixOS - Discourse: "How to use uutils-coreutils instead of the builtin coreutils?" (8904) - Comment 36]</small>}}


== Findutils ==
== Findutils ==
Line 45: Line 33:


[https://search.nixos.org/packages?show=uutils-diffutils Nixpkgs - <code>uutils-diffutils</code>]
[https://search.nixos.org/packages?show=uutils-diffutils Nixpkgs - <code>uutils-diffutils</code>]
=== Installation ===
To do a systemwide replacement of gnu utils with uutils you can use system.replaceDependencies. It should be noted that the name of the dependency is hardcoded in the binaries, therefore the name of the replacing dependency needs to have exactly the same length as the name of the source dependency. To do this declaratively this snippet should be added to your configs:
{{File|3={ 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];
      };
    }
  ];
}|name=/etc/nixos/configuration.nix|lang=nix}}
It should be noted that this is of course still quite a hacky solution, as the name of the resulting binaries will simply be padded with the char 'v'. A better solution might be found in the future.
<small>For details, see [https://discourse.nixos.org/t/how-to-use-uutils-coreutils-instead-of-the-builtin-coreutils/8904/36?u=malix NixOS - Discourse: "How to use uutils-coreutils instead of the builtin coreutils?" (8904) - Comment 36]</small>}}


[[Category:CLI_Applications]]
[[Category:CLI_Applications]]
[[Category:Applications]]
[[Category:Applications]]
[[Category:Rust]]]
[[Category:Rust]]]

Revision as of 16:48, 21 October 2025

The Uutils project reimplements ubiquitous command line utilities in memory-safe Rust.

Coreutils

Introduction

Uutils Coreutils is a cross-platform memory-safe reimplementation of GNU Coreutils in Rust

While all programs have been implemented, some options might be missing or different behavior might be experienced

For details, see Uutils Coreutils - GNU Coreutils Test Coverage

Though the main goal of the project is compatibility, Uutils Coreutils supports a few features that are not supported by GNU Coreutils

For details, see Uutils Coreutils - Extensions

Nixpkgs - uutils-coreutils

If you want a prefixed package for some reason, use uutils-coreutils instead

Findutils

☶︎
This section needs to be expanded. Further information may be found in the related discussion page. Please consult the pedia article metapage for guidelines on contributing.

Uutils Findutils is a cross-platform memory-safe reimplementation of GNU findutils: xargs, find, locate and updatedb

It aims to be a drop-in replacement of the original GNU findutils commands

Nixpkgs - uutils-findutils

Diffutils

☶︎
This section needs to be expanded. Further information may be found in the related discussion page. Please consult the pedia article metapage for guidelines on contributing.

Uutils Diffutils is is a cross-platform memory-safe reimplementation of GNU findutils: diff, cmp, diff3 and sdiff

It aims to be a drop-in replacement of the original GNU diffutils commands

Nixpkgs - uutils-diffutils

Installation

To do a systemwide replacement of gnu utils with uutils you can use system.replaceDependencies. It should be noted that the name of the dependency is hardcoded in the binaries, therefore the name of the replacing dependency needs to have exactly the same length as the name of the source dependency. To do this declaratively this snippet should be added to your configs:

❄︎ /etc/nixos/configuration.nix
{ 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];
      };
    }
  ];
}

It should be noted that this is of course still quite a hacky solution, as the name of the resulting binaries will simply be padded with the char 'v'. A better solution might be found in the future.

For details, see NixOS - Discourse: "How to use uutils-coreutils instead of the builtin coreutils?" (8904) - Comment 36}}]