Uutils: Difference between revisions

Malix (talk | contribs)
feat: Uutils
 
mNo edit summary
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The [https://uutils.github.io/ Uutils] project reimplements ubiquitous command line utilities in memory-safe Rust
The [https://uutils.github.io/ Uutils] project reimplements ubiquitous command line utilities in memory-safe Rust.


== Coreutils ==
== Coreutils ==
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>


=== Usage ===
[https://search.nixos.org/packages?show=uutils-diffutils Nixpkgs - <code>uutils-coreutils</code>]
We simply add [https://search.nixos.org/packages?show=uutils-coreutils-noprefix <code>uutils-coreutils-noprefix</code>] in <code>environment.systemsPackages</code>
 
{{File|3={ pkgs, ... }:
<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>
{
  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>  


== Findutils ==
== Findutils ==
[https://uutils.github.io/findutils/ Uutils Findutils] is a cross-platform memory-safe reimplementation of the GNU findutils: <code>xargs</code>, <code>find</code>, <code>locate</code> and <code>updatedb</code>
{{Expand|scope=section}}
[https://uutils.github.io/findutils/ Uutils Findutils] is a cross-platform memory-safe reimplementation of GNU findutils: <code>xargs</code>, <code>find</code>, <code>locate</code> and <code>updatedb</code>


It aims to be a drop-in replacement of the original GNU findutils commands
It aims to be a drop-in replacement of the original GNU findutils commands
Line 32: Line 27:


== Diffutils ==
== Diffutils ==
[https://uutils.github.io/diffutils/ Uutils Diffutils] is is a cross-platform memory-safe reimplementation of the GNU findutils: <code>diff</code>, <code>cmp</code>, <code>diff3</code> and <code>sdiff</code>.
{{Expand|scope=section}}
[https://uutils.github.io/diffutils/ Uutils Diffutils] is is a cross-platform memory-safe reimplementation of GNU findutils: <code>diff</code>, <code>cmp</code>, <code>diff3</code> and <code>sdiff</code>


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


[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 (_: "_") (builtins.stringLength pkgs.coreutils-full.version));
  coreutils-name = "coreuutils" + builtins.concatStringsSep ""
    (builtins.genList (_: "_") (builtins.stringLength pkgs.coreutils.version));
  findutils-name = "finduutils" + builtins.concatStringsSep ""
    (builtins.genList (_: "_") (builtins.stringLength pkgs.findutils.version));
  diffutils-name = "diffuutils" + builtins.concatStringsSep ""
    (builtins.genList (_: "_") (builtins.stringLength pkgs.diffutils.version));
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 '_'. 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:Applications]]
[[Category:Rust]]]