nixpkgs/pkgs/tools/misc/toybox/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
2.0 KiB
Nix
Raw Normal View History

{
stdenv, lib, fetchFromGitHub, which,
buildPackages, libxcrypt, libiconv,
enableStatic ? stdenv.hostPlatform.isStatic,
enableMinimal ? false,
extraConfig ? ""
}:
2023-01-15 15:44:38 +00:00
let
inherit (lib) optionals;
in
stdenv.mkDerivation rec {
pname = "toybox";
2022-08-17 00:53:22 +00:00
version = "0.8.8";
src = fetchFromGitHub {
owner = "landley";
repo = pname;
rev = version;
2022-08-17 00:53:22 +00:00
sha256 = "sha256-T3qE9xlcEoZOcY52XfYPpN34zzQl6mfcRnyuldnIvCk=";
};
2023-01-15 15:44:38 +00:00
depsBuildBuild = optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc ];
2022-09-29 16:28:05 +00:00
buildInputs = [
libxcrypt
2023-01-15 15:44:38 +00:00
] ++ optionals stdenv.isDarwin [
libiconv
2023-01-15 15:44:38 +00:00
] ++ optionals (enableStatic && stdenv.cc.libc ? static) [
2022-09-29 16:28:05 +00:00
stdenv.cc.libc
stdenv.cc.libc.static
];
postPatch = "patchShebangs .";
inherit extraConfig;
passAsFile = [ "extraConfig" ];
configurePhase = ''
make ${if enableMinimal then
"allnoconfig"
else
if stdenv.isFreeBSD then
"freebsd_defconfig"
else
if stdenv.isDarwin then
"macos_defconfig"
else
"defconfig"
}
cat $extraConfigPath .config > .config-
mv .config- .config
make oldconfig
'';
2023-01-15 15:44:38 +00:00
makeFlags = [ "PREFIX=$(out)/bin" ] ++ optionals enableStatic [ "LDFLAGS=--static" ];
2019-11-04 12:33:53 +00:00
installTargets = [ "install_flat" ];
# tests currently (as of 0.8.0) get stuck in an infinite loop...
# ...this is fixed in latest git, so doCheck can likely be enabled for next release
# see https://github.com/landley/toybox/commit/b928ec480cd73fd83511c0f5ca786d1b9f3167c3
#doCheck = true;
nativeCheckInputs = [ which ]; # used for tests with checkFlags = [ "DEBUG=true" ];
checkTarget = "tests";
NIX_CFLAGS_COMPILE = "-Wno-error";
meta = with lib; {
description = "Lightweight implementation of some Unix command line utilities";
homepage = "https://landley.net/toybox/";
license = licenses.bsd0;
platforms = with platforms; linux ++ darwin ++ freebsd;
maintainers = with maintainers; [ hhm ];
priority = 10;
};
}