···1{ stdenv, lib, stdenvNoCC
2+, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget
3+, buildPackages, splicePackages, newScope
4, bsdSetupHook, makeSetupHook, fetchcvs, groff, mandoc, byacc, flex
5, zlib
6, writeText, symlinkJoin
···14 tag = "netbsd-${lib.replaceStrings ["."] ["-"] version}-RELEASE";
15 };
1617+ otherSplices = {
18+ selfBuildBuild = pkgsBuildBuild.netbsd;
19+ selfBuildHost = pkgsBuildHost.netbsd;
20+ selfBuildTarget = pkgsBuildTarget.netbsd;
21+ selfHostHost = pkgsHostHost.netbsd;
22+ selfTargetTarget = pkgsTargetTarget.netbsd or {}; # might be missing
00023 };
2425+in lib.makeScopeWithSplicing
26+ splicePackages
27+ newScope
28+ otherSplices
29+ {}
30+ (self: let
31+ inherit (self) mkDerivation;
32+ in {
33+34+ # Why do we have splicing and yet do `nativeBuildInputs = with self; ...`?
35+ #
36+ # We use `lib.makeScopeWithSplicing` because this should be used for all
37+ # nested package sets which support cross, so the inner `callPackage` works
38+ # correctly. But for the inline packages we don't bother to use
39+ # `callPackage`.
40+ #
41+ # We still could have tried to `with` a big spliced packages set, but
42+ # splicing is jank and causes a number of bootstrapping infinite recursions
43+ # if one is not careful. Pulling deps out of the right package set directly
44+ # side-steps splicing entirely and avoids those footguns.
45+ #
46+ # For non-bootstrap-critical packages, we might as well use `callPackage` for
47+ # consistency with everything else, and maybe put in separate files too.
48+49+ compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isNetBSD) self.compat;
5051 mkDerivation = lib.makeOverridable (attrs: let
52 stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
···5657 extraPaths = [ ];
5859+ nativeBuildInputs = with buildPackages.netbsd; [
60 bsdSetupHook
61+ makeMinimal
62+ install tsort lorder mandoc groff statHook
63 ];
64+ buildInputs = with self; compatIfNeeded;
06566 OBJCOPY = if stdenv.isDarwin then "true" else "objcopy";
67 HOST_SH = "${buildPackages.bash}/bin/sh";
···8788 BSD_PATH = attrs.path;
8990+ strictDeps = true;
91+92 meta = with lib; {
93 maintainers = with maintainers; [ matthewbauer qyliss ];
94 platforms = platforms.unix;
···113 sha256 = "1xbzfd4i7allrkk1if74a8ymgpizyj0gkvdigzzj37qar7la7nc1";
114 version = "8.0";
115116+ buildInputs = with self; [];
117+ nativeBuildInputs = with buildPackages.netbsd; [ bsdSetupHook ];
118119 skipIncludesPhase = true;
120121 postPatch = ''
122 patchShebangs configure
123+ ${self.make.postPatch}
124 '';
125 buildPhase = ''
126 runHook preBuild
···139140 runHook postInstall
141 '';
142+ extraPaths = with self; [ make.src ] ++ make.extraPaths;
143 };
144145+ compat = mkDerivation (let
146+ version = "8.0";
147+ commonDeps = [ zlib ];
148+ in {
149 path = "tools/compat";
150 sha256 = "050449lq5gpxqsripdqip5ks49g5ypjga188nd3ss8dg1zf7ydz3";
151+ inherit version;
152153 setupHooks = [
154 ../../../build-support/setup-hooks/role.bash
155 ./compat-setup-hook.sh
156 ];
157158+ # the build system re-runs `./configure` with `HOST_CC` (which is their
159+ # name for Build CC) as a compiler to make `defs.mk`, which is installed
160+ depsBuildBuild = [ buildPackages.stdenv.cc ] ++ commonDeps;
161+ HOST_CC = "${buildPackages.stdenv.cc.targetPrefix}cc";
162+163+ nativeBuildInputs = with buildPackages.netbsd; commonDeps ++ [
164 bsdSetupHook
165 makeMinimal
166 ];
0167168+ buildInputs = with self; commonDeps;
000169170 # temporarily use gnuinstall for bootstrapping
171 # bsdinstall will be built later
···210 --subst-var-by out $out \
211 --subst-var-by version ${version}
212 '';
213+ extraPaths = with self; [ libc.src libutil.src
214 (fetchNetBSD "include" "8.0" "128m77k16i7frvk8kifhmxzk7a37m7z1s0bbmja3ywga6sx6v6sq")
215 (fetchNetBSD "external/bsd/flex" "8.0" "0yxcjshz9nj827qhmjwwjmzvmmqgaf0d25b42k7lj84vliwrgyr6")
216 (fetchNetBSD "sys/sys" "8.0" "0b0yjjy0c0cvk5nyffppqwxlwh2s1qr2xzl97a9ldck00dibar94")
217 ] ++ libutil.extraPaths ++ libc.extraPaths;
218+ });
219220 # HACK: to ensure parent directories exist. This emulates GNU
221 # install’s -D option. No alternative seems to exist in BSD install.
···228 path = "usr.bin/xinstall";
229 version = "8.0";
230 sha256 = "1f6pbz3qv1qcrchdxif8p5lbmnwl8b9nq615hsd3cyl4avd5bfqj";
231+ extraPaths = with self; [ mtree.src make.src ];
232+ nativeBuildInputs = with buildPackages.netbsd; [
233 bsdSetupHook
234 makeMinimal
235 mandoc groff
236 ];
237 skipIncludesPhase = true;
238+ buildInputs = with self; compatIfNeeded ++ [ fts ];
239 installPhase = ''
240 runHook preInstall
241···253 path = "include/fts.h";
254 sha256 = "01d4fpxvz1pgzfk5xznz5dcm0x0gdzwcsfm1h3d0xc9kc6hj2q77";
255 version = "8.0";
256+ nativeBuildInputs = with buildPackages.netbsd; [
257 bsdSetupHook
258 ];
259+ propagatedBuildInputs = with self; compatIfNeeded;
260+ extraPaths = with self; [
261 (fetchNetBSD "lib/libc/gen/fts.c" "8.0" "1a8hmf26242nmv05ipn3ircxb0jqmmi66rh78kkyi9vjwkfl3qn7")
262 (fetchNetBSD "lib/libc/include/namespace.h" "8.0" "1sjvh9nw3prnk4rmdwrfsxh6gdb9lmilkn46jcfh3q5c8glqzrd7")
263 (fetchNetBSD "lib/libc/gen/fts.3" "8.0" "1asxw0n3fhjdadwkkq3xplfgqgl3q32w1lyrvbakfa3gs0wz5zc1")
···289 path = "usr.bin/stat";
290 version = "8.0";
291 sha256 = "0z4r96id2r4cfy443rw2s1n52n186xm0lqvs8s3qjf4314z7r7yh";
292+ nativeBuildInputs = with buildPackages.netbsd; [
293 bsdSetupHook
294 makeMinimal
295 install mandoc groff
···304 statHook = makeSetupHook {
305 name = "netbsd-stat-hook";
306 } (writeText "netbsd-stat-hook-impl" ''
307+ makeFlagsArray+=(TOOL_STAT=${self.stat}/bin/stat)
308 '');
309310 tsort = mkDerivation {
311 path = "usr.bin/tsort";
312 version = "8.0";
313 sha256 = "1dqvf9gin29nnq3c4byxc7lfd062pg7m84843zdy6n0z63hnnwiq";
314+ nativeBuildInputs = with buildPackages.netbsd; [
315 bsdSetupHook
316 makeMinimal
317 install mandoc groff
···322 path = "usr.bin/lorder";
323 version = "8.0";
324 sha256 = "0rjf9blihhm0n699vr2bg88m4yjhkbxh6fxliaay3wxkgnydjwn2";
325+ nativeBuildInputs = with buildPackages.netbsd; [
326 bsdSetupHook
327 makeMinimal
328 install mandoc groff
···364 path = "usr.sbin/mtree";
365 version = "8.0";
366 sha256 = "0hanmzm8bgwz2bhsinmsgfmgy6nbdhprwmgwbyjm6bl17vgn7vid";
367+ extraPaths = with self; [ mknod.src ];
368 };
369370 mknod = mkDerivation {
···423 version = "8.0";
424 sha256 = "092y7db7k4kh2jq8qc55126r5qqvlb8lq8mhmy5ipbi36hwb4zrz";
425 HOSTPROG = "tic";
426+ buildInputs = with self; compatIfNeeded;
427+ nativeBuildInputs = with buildPackages.netbsd; [
428 bsdSetupHook
429 makeMinimal
430 install mandoc groff nbperf
431 ];
432 makeFlags = [ "TOOLDIR=$(out)" ];
433+ extraPaths = with self; [
434 libterminfo.src
435 (fetchNetBSD "usr.bin/tic" "8.0" "0diirnzmdnpc5bixyb34c9rid9paw2a4zfczqrpqrfvjsf1nnljf")
436 (fetchNetBSD "tools/Makefile.host" "8.0" "1p23dsc4qrv93vc6gzid9w2479jwswry9qfn88505s0pdd7h6nvp")
···456 version = "8.0";
457 sha256 = "0piyn8lgdqxwz9wkgc2plzp2xpj93fs4xncri8l0jfas9rv5j2m5";
458 NIX_CFLAGS_COMPILE = [ "-DMAKE_BOOTSTRAP" ];
459+ nativeBuildInputs = with buildPackages.netbsd; [
460 bsdSetupHook
461 makeMinimal install mandoc byacc flex
462 ];
463+ buildInputs = with self; compatIfNeeded;
464+ extraPaths = with self; [ cksum.src ];
465 };
466 ##
467 ## END COMMAND LINE TOOLS
···474 path = "include";
475 version = "8.0";
476 sha256 = "128m77k16i7frvk8kifhmxzk7a37m7z1s0bbmja3ywga6sx6v6sq";
477+ nativeBuildInputs = with buildPackages.netbsd; [
478 bsdSetupHook
479 makeMinimal
480 install mandoc groff nbperf rpcgen
481 ];
482+ extraPaths = with self; [ common.src ];
483 headersOnly = true;
484 noCC = true;
485+ meta.platforms = lib.platforms.netbsd;
486+ makeFlags = [ "RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp" ];
487 };
488489 common = mkDerivation {
490 path = "common";
491 version = "8.0";
492 sha256 = "1fsm2b7p7zkhiz523jw75088cq2h39iknp0fp3di9a64bikwbhi1";
493+ noCC = true;
494 };
495496+ sys-headers = mkDerivation {
497+ pname = "sys-headers";
498 path = "sys";
499 version = "8.0";
500 sha256 = "123ilg8fqmp69bw6bs6nh98fpi1v2n9lamrzar61p27ji6sj7g0w";
501502 CONFIG = "GENERIC";
503504+ propagatedBuildInputs = with self; [ include ];
505+ nativeBuildInputs = with buildPackages.netbsd; [
506 bsdSetupHook
507 makeMinimal install tsort lorder statHook uudecode config genassym
508 ];
···527 '';
528529 meta.platforms = lib.platforms.netbsd;
530+ extraPaths = with self; [ common.src ];
531+532+ installPhase = "includesPhase";
533+ dontBuild = true;
534+ noCC = true;
535+ };
536+537+ # The full kernel. We do the funny thing of overridding the headers to the
538+ # full kernal and not vice versa to avoid infinite recursion -- the headers
539+ # come earlier in the bootstrap.
540+ sys = self.sys-headers.override {
541+ pname = "sys";
542+ installPhase = null;
543+ noCC = false;
544+ dontBuild = false;
545 };
546547 headers = symlinkJoin {
548 name = "netbsd-headers-8.0";
549+ paths = with self; [
550+ include
551+ sys-headers
552+ libpthread-headers
553+ ];
554+ meta.platforms = lib.platforms.netbsd;
555 };
556 ##
557 ## END HEADERS
···564 path = "lib/libutil";
565 version = "8.0";
566 sha256 = "077syyxd303m4x7avs5nxzk4c9n13d5lyk5aicsacqjvx79qrk3i";
567+ extraPaths = with self; [ common.src ];
568 };
569570 libedit = mkDerivation {
571 path = "lib/libedit";
572 version = "8.0";
573 sha256 = "0pmqh2mkfp70bwchiwyrkdyq9jcihx12g1awd6alqi9bpr3f9xmd";
574+ buildInputs = with self; [ libterminfo libcurses ];
575+ propagatedBuildInputs = with self; compatIfNeeded;
576 postPatch = ''
577 sed -i '1i #undef bool_t' el.h
578 substituteInPlace config.h \
···590 path = "lib/libterminfo";
591 version = "8.0";
592 sha256 = "14gp0d6fh6zjnbac2yjhyq5m6rca7gm6q1s9gilhzpdgl9m7vb9r";
593+ nativeBuildInputs = with buildPackages.netbsd; [
594 makeMinimal install tsort lorder mandoc statHook nbperf tic
595 ];
596+ buildInputs = with self; compatIfNeeded;
597 SHLIBINSTALLDIR = "$(out)/lib";
598 postPatch = ''
599 substituteInPlace term.c --replace /usr/share $out/share
···606 postInstall = ''
607 make -C $BSDSRCDIR/share/terminfo BINDIR=$out/share install
608 '';
609+ extraPaths = with self; [
610 (fetchNetBSD "share/terminfo" "8.0" "18db0fk1dw691vk6lsm6dksm4cf08g8kdm0gc4052ysdagg2m6sm")
611 ];
612 };
···615 path = "lib/libcurses";
616 version = "8.0";
617 sha256 = "0azhzh1910v24dqx45zmh4z4dl63fgsykajrbikx5xfvvmkcq7xs";
618+ buildInputs = with self; [ libterminfo ];
619 NIX_CFLAGS_COMPILE = [
620 "-D__scanflike(a,b)="
621 "-D__va_list=va_list"
622 "-D__warn_references(a,b)="
623 ] ++ lib.optional stdenv.isDarwin "-D__strong_alias(a,b)=";
624+ propagatedBuildInputs = with self; compatIfNeeded;
625 MKDOC = "no"; # missing vfontedpr
626 postPatch = lib.optionalString (!stdenv.isDarwin) ''
627 substituteInPlace printw.c \
···674 meta.platforms = lib.platforms.netbsd;
675 };
676677+ libpthread-headers = mkDerivation {
678+ pname = "libpthread-headers";
679 path = "lib/libpthread";
680 version = "8.0";
681 sha256 = "0pcz61klc3ijf5z2zf8s78nj7bwjfblzjllx7vr4z5qv3m0sdb3j";
682+ installPhase = "includesPhase";
683+ dontBuild = true;
684+ noCC = true;
685 meta.platforms = lib.platforms.netbsd;
686 };
687688+ libpthread = self.libpthread-headers.override {
689+ pname = "libpthread";
690+ installPhase = null;
691+ noCC = false;
692+ dontBuild = false;
693+ };
694+695 libresolv = mkDerivation {
696 path = "lib/libresolv";
697 version = "8.0";
698 sha256 = "11vpb3p2343wyrhw4v9gwz7i0lcpb9ysmfs9gsx56b5gkgipdy4v";
699 meta.platforms = lib.platforms.netbsd;
700+ extraPaths = with self; [ libc.src ];
701 };
702703 libm = mkDerivation {
···712 version = "8.0";
713 sha256 = "0w6y5v3binm7gf2kn7y9jja8k18rhnyl55cvvfnfipjqdxvxd9jd";
714 meta.platforms = lib.platforms.netbsd;
715+ extraPaths = with self; [ libc.src ];
716 };
717718 csu = mkDerivation {
···720 version = "8.0";
721 sha256 = "0630lbvz6v4ic13bfg8ccwfhqkgcv76bfdw9f36rfsnwfgpxqsmq";
722 meta.platforms = lib.platforms.netbsd;
723+ nativeBuildInputs = with buildPackages.netbsd; [
724 bsdSetupHook
725 makeMinimal
726 install mandoc groff flex
727 byacc genassym gencat lorder tsort statHook
728 ];
729+ buildInputs = with self; [ headers ];
730+ extraPaths = with self; [ sys.src ld_elf_so.src ];
731 };
732733 ld_elf_so = mkDerivation {
···740 SHLINKINSTALLDIR = "/usr/libexec";
741 USE_FORT = "yes";
742 makeFlags = [ "CLIBOBJ=${stdenv.cc.libc}/lib" ];
743+ extraPaths = with self; [ libc.src ] ++ libc.extraPaths;
744 };
745746 libc = mkDerivation {
···749 sha256 = "0lgbc58qgn8kwm3l011x1ml1kgcf7jsgq7hbf0hxhlbvxq5bljl3";
750 USE_FORT = "yes";
751 MKPROFILE = "no";
752+ extraPaths = with self; [
753 common.src i18n_module.src sys.src
754 ld_elf_so.src libpthread.src libm.src libresolv.src
755 librpcsvc.src libutil.src librt.src libcrypt.src
756 ];
757+ nativeBuildInputs = with buildPackages.netbsd; [
758 bsdSetupHook
759 makeMinimal
760 install mandoc groff flex
761 byacc genassym gencat lorder tsort statHook rpcgen
762 ];
763+ buildInputs = with self; [ headers csu ];
764+ NIX_CFLAGS_COMPILE = "-B${self.csu}/lib";
765 meta.platforms = lib.platforms.netbsd;
766 SHLIBINSTALLDIR = "$(out)/lib";
767 NLSDIR = "$(out)/share/nls";
768 makeFlags = [ "FILESDIR=$(out)/var/db"];
769 postInstall = ''
770+ pushd ${self.headers}
771 find . -type d -exec mkdir -p $out/\{} \;
772 find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
773 popd
774775+ pushd ${self.csu}
776 find . -type d -exec mkdir -p $out/\{} \;
777 find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
778 popd
···806 make -C $BSDSRCDIR/lib/libcrypt $makeFlags install
807 '';
808 postPatch = ''
809+ sed -i 's,/usr\(/include/sys/syscall.h\),${self.headers}\1,g' \
810 sys/Makefile.inc ../librt/sys/Makefile.inc
811 '';
812 };
···844 # END MISCELLANEOUS
845 #
846847+})
00
+4-4
pkgs/top-level/all-packages.nix
···10316 libcCross1 =
10317 if stdenv.targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
10318 else if stdenv.targetPlatform.libc == "libSystem" then darwin.xcode
10319- else if stdenv.targetPlatform.libc == "nblibc" then netbsd.headers
10320 else null;
10321 binutils1 = wrapBintoolsWith {
10322 bintools = binutils-unwrapped;
···14553 else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
14554 else if stdenv.targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries
14555 else if name == "libSystem" then targetPackages.darwin.xcode
14556- else if name == "nblibc" then targetPackages.netbsdCross.libc
14557 else if name == "wasilibc" then targetPackages.wasilibc or wasilibc
14558 else if name == "relibc" then targetPackages.relibc or relibc
14559 else if stdenv.targetPlatform.isGhcjs then null
···30977 name = "bsd-setup-hook";
30978 } ../os-specific/bsd/setup-hook.sh;
3097930980- netbsd = callPackages ../os-specific/bsd/netbsd {};
30981- netbsdCross = callPackages ../os-specific/bsd/netbsd {
30982 stdenv = crossLibcStdenv;
30983 };
30984
···10316 libcCross1 =
10317 if stdenv.targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
10318 else if stdenv.targetPlatform.libc == "libSystem" then darwin.xcode
10319+ else if stdenv.targetPlatform.libc == "nblibc" then targetPackages.netbsdCross.headers
10320 else null;
10321 binutils1 = wrapBintoolsWith {
10322 bintools = binutils-unwrapped;
···14553 else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
14554 else if stdenv.targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries
14555 else if name == "libSystem" then targetPackages.darwin.xcode
14556+ else if name == "nblibc" then targetPackages.netbsdCross.libc or netbsdCross.libc
14557 else if name == "wasilibc" then targetPackages.wasilibc or wasilibc
14558 else if name == "relibc" then targetPackages.relibc or relibc
14559 else if stdenv.targetPlatform.isGhcjs then null
···30977 name = "bsd-setup-hook";
30978 } ../os-specific/bsd/setup-hook.sh;
3097930980+ netbsd = callPackage ../os-specific/bsd/netbsd {};
30981+ netbsdCross = callPackage ../os-specific/bsd/netbsd {
30982 stdenv = crossLibcStdenv;
30983 };
30984