nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 bc,
4 fetchurl,
5 getopt,
6 pkgsMusl ? { },
7 stdenv,
8 tzdata,
9}:
10
11stdenv.mkDerivation (finalAttrs: {
12 pname = "bmake";
13 version = "20251111";
14
15 src = fetchurl {
16 url = "https://www.crufty.net/ftp/pub/sjg/bmake-${finalAttrs.version}.tar.gz";
17 hash = "sha256-RaP4UVZ3uo85M9ghP0u2EaXDyIOAvi5GIi+kRwlQYGA=";
18 };
19
20 patches = [
21 # decouple tests from build phase
22 ./002-dont-test-while-installing.diff
23 # preserve PATH from build env in unit tests
24 ./003-fix-unexport-env-test.diff
25 # Always enable ksh test since it checks in a impure location /bin/ksh
26 ./004-unconditional-ksh-test.diff
27 ];
28
29 outputs = [
30 "out"
31 "man"
32 ];
33
34 nativeBuildInputs = [
35 getopt
36 ];
37
38 nativeCheckInputs = [
39 bc
40 tzdata
41 ];
42
43 # The generated makefile is a small wrapper for calling ./boot-strap with a
44 # given op. On a case-insensitive filesystem this generated makefile clobbers
45 # a distinct, shipped Makefile and causes infinite recursion during tests
46 # which eventually fail with "fork: Resource temporarily unavailable"
47 configureFlags = [
48 "--without-makefile"
49 ];
50
51 # Disabled tests:
52 # * cmd-interrupt: tries to `SIGINT` make itself, flaky as a result
53 # * directive-export{,-gmake}: another failure related to TZ variables
54 # * opt-keep-going-indirect: not yet known
55 # * varmod-localtime: musl doesn't support TZDIR and this test relies on impure, implicit paths
56 env.BROKEN_TESTS = lib.concatStringsSep " " (
57 [
58 "cmd-interrupt"
59 "directive-export"
60 "directive-export-gmake"
61 "opt-keep-going-indirect"
62 "varmod-localtime"
63 ]
64 # TODO: drop the name-conditioning on stdenv rebuild
65 ++ lib.optional (stdenv.isDarwin && lib.getName stdenv != "bootstrap-stage1-stdenv-darwin") "export"
66 );
67
68 strictDeps = true;
69
70 doCheck = true;
71
72 # Make tests work with musl
73 # * Disable deptgt-delete_on_error test (alpine does this too)
74 # * Disable shell-ksh test (ksh doesn't compile with musl)
75 # * Fix test failing due to different strerror(3) output for musl and glibc
76 postPatch = lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
77 sed -i unit-tests/Makefile \
78 -e '/deptgt-delete_on_error/d' \
79 -e '/shell-ksh/d'
80 substituteInPlace unit-tests/opt-chdir.exp --replace "File name" "Filename"
81 '';
82
83 buildPhase = ''
84 runHook preBuild
85
86 ./boot-strap --prefix=$out -o . op=build
87
88 runHook postBuild
89 '';
90
91 installPhase = ''
92 runHook preInstall
93
94 ./boot-strap --prefix=$out -o . op=install
95
96 runHook postInstall
97 '';
98
99 checkPhase = ''
100 runHook preCheck
101
102 ./boot-strap -o . op=test
103
104 runHook postCheck
105 '';
106
107 setupHook = ./setup-hook.sh;
108
109 passthru = {
110 tests = {
111 bmakeMusl = pkgsMusl.bmake or null;
112 };
113 };
114
115 meta = {
116 homepage = "https://www.crufty.net/help/sjg/bmake.html";
117 description = "Portable version of NetBSD 'make'";
118 license = lib.licenses.bsd3;
119 mainProgram = "bmake";
120 maintainers = with lib.maintainers; [ thoughtpolice ];
121 platforms = lib.platforms.unix;
122 # requires strip
123 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
124 };
125})
126# TODO: report the quirks and patches to bmake devteam (especially the Musl one)
127# TODO: investigate static support