Single binary coreutils

The software I am attempting to package with Nix relies on the fact that, for example, bin/sleep is a real binary and not a symlink to the single coreutils binary the Nix stdenv uses.

My default.nix is nothing out of the ordinary:

{ nixpkgs ? import <nixpkgs> {  } }:

nixpkgs.stdenv.mkDerivation rec {
  name = "mything";
  src = ./.;
  builder = nixpkgs.buildGoModule {
    inherit name src;
    vendorSha256 = null;
  };
}

I can see that it is possible to use singleBinary = false with coreutils in order to revert to the traditional behavior. However, I do not understand how I can use, define or call nixpkgs.stdenv in such a way as to have this happen. As you may have guessed from the vagueness of my language I am new to writing Nix (although I have been using NixOS as a daily driver for some time now).

Any help gratefully received.

1 Like

Can’t you add the overridden coreutils to the buildInputs? Also, are you sure that you want to use a go program as your builder?

I’d also say you’re looking at wrapping the result so it has access to that sleep binary if it needs that at runtime.

Fundamentally though that package should really be fixed upstream to not fail if sleep is a link. A large amount of distros symlink from a single coreutils/busybox or whatever

Thanks for your reply. Without going into too much detail it is a fundamental part of what this code does to ensure binaries really are binaries. It is a system level package.

I don’t understand what you mean by “wrapping the result” and I’d be very grateful if you could explain that.

If the program is so anti-symlink you might be in for a tough time on nix/nixos

A tool that ensures things really are binaries sounds interesting but I’d be interested to know why a symlink that does go to a “real” binary is a no-go. If it’s all hush-hush I guess I’ll need to do my own research on the topic.


This is what I mean by wrapping. Making it so your tool has a path that directly looks at a “real” sleep binary