diff options
Diffstat (limited to 'pkgs/os-specific/bsd')
-rw-r--r-- | pkgs/os-specific/bsd/default.nix | 5 | ||||
-rw-r--r-- | pkgs/os-specific/bsd/netbsd/default.nix | 454 | ||||
-rw-r--r-- | pkgs/os-specific/bsd/setup-hook.sh (renamed from pkgs/os-specific/bsd/netbsd/builder.sh) | 24 |
3 files changed, 331 insertions, 152 deletions
diff --git a/pkgs/os-specific/bsd/default.nix b/pkgs/os-specific/bsd/default.nix deleted file mode 100644 index ee7158e2a8c..00000000000 --- a/pkgs/os-specific/bsd/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ callPackages, recurseIntoAttrs }: - -{ - netbsd = recurseIntoAttrs (callPackages ./netbsd {}); -} diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 6d01bff3b3e..32ec884aac3 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -1,5 +1,10 @@ -{ stdenv, stdenvNoCC, fetchcvs, lib, groff, mandoc, zlib, bison, flex -, writeText, buildPackages, splicePackages, symlinkJoin }: +{ stdenv, lib, stdenvNoCC +, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget +, buildPackages, splicePackages, newScope +, bsdSetupHook, makeSetupHook, fetchcvs, groff, mandoc, byacc, flex +, zlib +, writeText, symlinkJoin +}: let fetchNetBSD = path: version: sha256: fetchcvs { @@ -9,30 +14,54 @@ let tag = "netbsd-${lib.replaceStrings ["."] ["-"] version}-RELEASE"; }; - # Splice packages so we get the correct package when using - # nativeBuildInputs... - nbSplicedPackages = splicePackages { - pkgsBuildBuild = buildPackages.buildPackages.netbsd; - pkgsBuildHost = buildPackages.netbsd; - pkgsBuildTarget = {}; - pkgsHostHost = {}; - pkgsHostTarget = netbsd; - pkgsTargetTarget = {}; + otherSplices = { + selfBuildBuild = pkgsBuildBuild.netbsd; + selfBuildHost = pkgsBuildHost.netbsd; + selfBuildTarget = pkgsBuildTarget.netbsd; + selfHostHost = pkgsHostHost.netbsd; + selfTargetTarget = pkgsTargetTarget.netbsd or {}; # might be missing }; - netbsd = with nbSplicedPackages; { +in lib.makeScopeWithSplicing + splicePackages + newScope + otherSplices + {} + (self: let + inherit (self) mkDerivation; + in { + + # Why do we have splicing and yet do `nativeBuildInputs = with self; ...`? + # + # We use `lib.makeScopeWithSplicing` because this should be used for all + # nested package sets which support cross, so the inner `callPackage` works + # correctly. But for the inline packages we don't bother to use + # `callPackage`. + # + # We still could have tried to `with` a big spliced packages set, but + # splicing is jank and causes a number of bootstrapping infinite recursions + # if one is not careful. Pulling deps out of the right package set directly + # side-steps splicing entirely and avoids those footguns. + # + # For non-bootstrap-critical packages, we might as well use `callPackage` for + # consistency with everything else, and maybe put in separate files too. + + compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isNetBSD) self.compat; mkDerivation = lib.makeOverridable (attrs: let stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv; in stdenv'.mkDerivation ({ name = "${attrs.pname or (baseNameOf attrs.path)}-netbsd-${attrs.version}"; - src = attrs.src or fetchNetBSD attrs.path attrs.version attrs.sha256; + src = fetchNetBSD attrs.path attrs.version attrs.sha256; extraPaths = [ ]; - nativeBuildInputs = [ makeMinimal install tsort lorder mandoc groff stat ]; - buildInputs = [ compat ]; - # depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install tsort lorder mandoc groff statHook + ]; + buildInputs = with self; compatIfNeeded; OBJCOPY = if stdenv.isDarwin then "true" else "objcopy"; HOST_SH = "${buildPackages.bash}/bin/sh"; @@ -56,9 +85,9 @@ let LD = "${stdenv'.cc.targetPrefix or ""}ld"; STRIP = "${stdenv'.cc.targetPrefix or ""}strip"; - NETBSD_PATH = attrs.path; + BSD_PATH = attrs.path; - builder = ./builder.sh; + strictDeps = true; meta = with lib; { maintainers = with maintainers; [ matthewbauer qyliss ]; @@ -84,14 +113,14 @@ let sha256 = "1xbzfd4i7allrkk1if74a8ymgpizyj0gkvdigzzj37qar7la7nc1"; version = "8.0"; - buildInputs = []; - nativeBuildInputs = []; + buildInputs = with self; []; + nativeBuildInputs = with buildPackages.netbsd; [ bsdSetupHook ]; skipIncludesPhase = true; postPatch = '' patchShebangs configure - ${make.postPatch} + ${self.make.postPatch} ''; buildPhase = '' runHook preBuild @@ -106,32 +135,38 @@ let install -D nbmake $out/bin/nbmake ln -s $out/bin/nbmake $out/bin/make mkdir -p $out/share - cp -r $NETBSDSRCDIR/share/mk $out/share/mk + cp -r $BSDSRCDIR/share/mk $out/share/mk runHook postInstall ''; - extraPaths = [ make.src ] ++ make.extraPaths; + extraPaths = with self; [ make.src ] ++ make.extraPaths; }; - compat = if stdenv.hostPlatform.isNetBSD then stdenv else mkDerivation rec { + compat = mkDerivation (let + version = "8.0"; + commonDeps = [ zlib ]; + in { path = "tools/compat"; sha256 = "050449lq5gpxqsripdqip5ks49g5ypjga188nd3ss8dg1zf7ydz3"; - version = "8.0"; + inherit version; setupHooks = [ ../../../build-support/setup-hooks/role.bash ./compat-setup-hook.sh ]; - # override defaults to prevent infinite recursion - nativeBuildInputs = [ makeMinimal ]; - buildInputs = [ zlib ]; - # the build system re-runs `./configure` with `HOST_CC` (which is their # name for Build CC) as a compiler to make `defs.mk`, which is installed - depsBuildBuild = [ buildPackages.stdenv.cc ] ++ buildInputs; + depsBuildBuild = [ buildPackages.stdenv.cc ] ++ commonDeps; HOST_CC = "${buildPackages.stdenv.cc.targetPrefix}cc"; + nativeBuildInputs = with buildPackages.netbsd; commonDeps ++ [ + bsdSetupHook + makeMinimal + ]; + + buildInputs = with self; commonDeps; + # temporarily use gnuinstall for bootstrapping # bsdinstall will be built later makeFlags = [ @@ -148,24 +183,24 @@ let # why aren't these installed by netbsd? install -D compat_defs.h $out/include/compat_defs.h - install -D $NETBSDSRCDIR/include/cdbw.h $out/include/cdbw.h - install -D $NETBSDSRCDIR/sys/sys/cdbr.h $out/include/cdbr.h - install -D $NETBSDSRCDIR/sys/sys/featuretest.h \ + install -D $BSDSRCDIR/include/cdbw.h $out/include/cdbw.h + install -D $BSDSRCDIR/sys/sys/cdbr.h $out/include/cdbr.h + install -D $BSDSRCDIR/sys/sys/featuretest.h \ $out/include/sys/featuretest.h - install -D $NETBSDSRCDIR/sys/sys/md5.h $out/include/md5.h - install -D $NETBSDSRCDIR/sys/sys/rmd160.h $out/include/rmd160.h - install -D $NETBSDSRCDIR/sys/sys/sha1.h $out/include/sha1.h - install -D $NETBSDSRCDIR/sys/sys/sha2.h $out/include/sha2.h - install -D $NETBSDSRCDIR/sys/sys/queue.h $out/include/sys/queue.h - install -D $NETBSDSRCDIR/include/vis.h $out/include/vis.h - install -D $NETBSDSRCDIR/include/db.h $out/include/db.h - install -D $NETBSDSRCDIR/include/netconfig.h $out/include/netconfig.h - install -D $NETBSDSRCDIR/include/rpc/types.h $out/include/rpc/types.h - install -D $NETBSDSRCDIR/include/utmpx.h $out/include/utmpx.h - install -D $NETBSDSRCDIR/include/tzfile.h $out/include/tzfile.h - install -D $NETBSDSRCDIR/sys/sys/tree.h $out/include/sys/tree.h - install -D $NETBSDSRCDIR/include/nl_types.h $out/include/nl_types.h - install -D $NETBSDSRCDIR/include/stringlist.h $out/include/stringlist.h + install -D $BSDSRCDIR/sys/sys/md5.h $out/include/md5.h + install -D $BSDSRCDIR/sys/sys/rmd160.h $out/include/rmd160.h + install -D $BSDSRCDIR/sys/sys/sha1.h $out/include/sha1.h + install -D $BSDSRCDIR/sys/sys/sha2.h $out/include/sha2.h + install -D $BSDSRCDIR/sys/sys/queue.h $out/include/sys/queue.h + install -D $BSDSRCDIR/include/vis.h $out/include/vis.h + install -D $BSDSRCDIR/include/db.h $out/include/db.h + install -D $BSDSRCDIR/include/netconfig.h $out/include/netconfig.h + install -D $BSDSRCDIR/include/rpc/types.h $out/include/rpc/types.h + install -D $BSDSRCDIR/include/utmpx.h $out/include/utmpx.h + install -D $BSDSRCDIR/include/tzfile.h $out/include/tzfile.h + install -D $BSDSRCDIR/sys/sys/tree.h $out/include/sys/tree.h + install -D $BSDSRCDIR/include/nl_types.h $out/include/nl_types.h + install -D $BSDSRCDIR/include/stringlist.h $out/include/stringlist.h '' + lib.optionalString stdenv.isDarwin '' mkdir -p $out/include/ssp touch $out/include/ssp/ssp.h @@ -175,12 +210,12 @@ let --subst-var-by out $out \ --subst-var-by version ${version} ''; - extraPaths = [ libc.src libutil.src + extraPaths = with self; [ libc.src libutil.src (fetchNetBSD "include" "8.0" "128m77k16i7frvk8kifhmxzk7a37m7z1s0bbmja3ywga6sx6v6sq") (fetchNetBSD "external/bsd/flex" "8.0" "0yxcjshz9nj827qhmjwwjmzvmmqgaf0d25b42k7lj84vliwrgyr6") (fetchNetBSD "sys/sys" "8.0" "0b0yjjy0c0cvk5nyffppqwxlwh2s1qr2xzl97a9ldck00dibar94") ] ++ libutil.extraPaths ++ libc.extraPaths; - }; + }); # HACK: to ensure parent directories exist. This emulates GNU # install’s -D option. No alternative seems to exist in BSD install. @@ -193,10 +228,14 @@ let path = "usr.bin/xinstall"; version = "8.0"; sha256 = "1f6pbz3qv1qcrchdxif8p5lbmnwl8b9nq615hsd3cyl4avd5bfqj"; - extraPaths = [ mtree.src make.src ]; - nativeBuildInputs = [ makeMinimal mandoc groff ]; + extraPaths = with self; [ mtree.src make.src ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + mandoc groff + ]; skipIncludesPhase = true; - buildInputs = [ compat fts ]; + buildInputs = with self; compatIfNeeded ++ [ fts ]; installPhase = '' runHook preInstall @@ -214,9 +253,11 @@ let path = "include/fts.h"; sha256 = "01d4fpxvz1pgzfk5xznz5dcm0x0gdzwcsfm1h3d0xc9kc6hj2q77"; version = "8.0"; - nativeBuildInputs = [ ]; - propagatedBuildInputs = [ compat ]; - extraPaths = [ + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + ]; + propagatedBuildInputs = with self; compatIfNeeded; + extraPaths = with self; [ (fetchNetBSD "lib/libc/gen/fts.c" "8.0" "1a8hmf26242nmv05ipn3ircxb0jqmmi66rh78kkyi9vjwkfl3qn7") (fetchNetBSD "lib/libc/include/namespace.h" "8.0" "1sjvh9nw3prnk4rmdwrfsxh6gdb9lmilkn46jcfh3q5c8glqzrd7") (fetchNetBSD "lib/libc/gen/fts.3" "8.0" "1asxw0n3fhjdadwkkq3xplfgqgl3q32w1lyrvbakfa3gs0wz5zc1") @@ -243,25 +284,49 @@ let ]; }; + # Don't add this to nativeBuildInputs directly. Use statHook instead. stat = mkDerivation { path = "usr.bin/stat"; version = "8.0"; sha256 = "0z4r96id2r4cfy443rw2s1n52n186xm0lqvs8s3qjf4314z7r7yh"; - nativeBuildInputs = [ makeMinimal install mandoc groff ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install mandoc groff + ]; }; + # stat isn't in POSIX, and NetBSD stat supports a completely + # different range of flags than GNU stat, so including it in PATH + # breaks stdenv. Work around that with a hook that will point + # NetBSD's build system and NetBSD stat without including it in + # PATH. + statHook = makeSetupHook { + name = "netbsd-stat-hook"; + } (writeText "netbsd-stat-hook-impl" '' + makeFlagsArray+=(TOOL_STAT=${self.stat}/bin/stat) + ''); + tsort = mkDerivation { path = "usr.bin/tsort"; version = "8.0"; sha256 = "1dqvf9gin29nnq3c4byxc7lfd062pg7m84843zdy6n0z63hnnwiq"; - nativeBuildInputs = [ makeMinimal install mandoc groff ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install mandoc groff + ]; }; lorder = mkDerivation { path = "usr.bin/lorder"; version = "8.0"; sha256 = "0rjf9blihhm0n699vr2bg88m4yjhkbxh6fxliaay3wxkgnydjwn2"; - nativeBuildInputs = [ makeMinimal install mandoc groff ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install mandoc groff + ]; }; ## ## END BOOTSTRAPPING @@ -278,17 +343,17 @@ let # make needs this to pick up our sys make files export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\"" - substituteInPlace $NETBSDSRCDIR/share/mk/bsd.lib.mk \ + substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \ --replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB=' - substituteInPlace $NETBSDSRCDIR/share/mk/bsd.kinc.mk \ + substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \ --replace /bin/rm rm '' + lib.optionalString stdenv.isDarwin '' - substituteInPlace $NETBSDSRCDIR/share/mk/bsd.sys.mk \ + substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \ --replace '-Wl,--fatal-warnings' "" \ --replace '-Wl,--warn-shared-textrel' "" ''; postInstall = '' - make -C $NETBSDSRCDIR/share/mk FILESDIR=$out/share/mk install + make -C $BSDSRCDIR/share/mk FILESDIR=$out/share/mk install ''; extraPaths = [ (fetchNetBSD "share/mk" "8.0" "033q4w3rmvwznz6m7fn9xcf13chyhwwl8ijj3a9mrn80fkwm55qs") @@ -299,7 +364,7 @@ let path = "usr.sbin/mtree"; version = "8.0"; sha256 = "0hanmzm8bgwz2bhsinmsgfmgy6nbdhprwmgwbyjm6bl17vgn7vid"; - extraPaths = [ mknod.src ]; + extraPaths = with self; [ mknod.src ]; }; mknod = mkDerivation { @@ -358,15 +423,46 @@ let version = "8.0"; sha256 = "092y7db7k4kh2jq8qc55126r5qqvlb8lq8mhmy5ipbi36hwb4zrz"; HOSTPROG = "tic"; - buildInputs = [ compat ]; - nativeBuildInputs = [ makeMinimal install mandoc groff nbperf ]; + buildInputs = with self; compatIfNeeded; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install mandoc groff nbperf + ]; makeFlags = [ "TOOLDIR=$(out)" ]; - extraPaths = [ + extraPaths = with self; [ libterminfo.src (fetchNetBSD "usr.bin/tic" "8.0" "0diirnzmdnpc5bixyb34c9rid9paw2a4zfczqrpqrfvjsf1nnljf") (fetchNetBSD "tools/Makefile.host" "8.0" "1p23dsc4qrv93vc6gzid9w2479jwswry9qfn88505s0pdd7h6nvp") ]; }; + + uudecode = mkDerivation { + path = "usr.bin/uudecode"; + version = "8.0"; + sha256 = "00a3zmh15pg4vx6hz0kaa5mi8d2b1sj4h512d7p6wbvxq6mznwcn"; + NIX_CFLAGS_COMPILE = lib.optional stdenv.isLinux "-DNO_BASE64"; + }; + + cksum = mkDerivation { + path = "usr.bin/cksum"; + version = "8.0"; + sha256 = "0327820171djn9dzb2q1arypxw2zsxiixnd1ahy34dagd9cwcphj"; + meta.platforms = lib.platforms.netbsd; + }; + + config = mkDerivation { + path = "usr.bin/config"; + version = "8.0"; + sha256 = "0piyn8lgdqxwz9wkgc2plzp2xpj93fs4xncri8l0jfas9rv5j2m5"; + NIX_CFLAGS_COMPILE = [ "-DMAKE_BOOTSTRAP" ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal install mandoc byacc flex + ]; + buildInputs = with self; compatIfNeeded; + extraPaths = with self; [ cksum.src ]; + }; ## ## END COMMAND LINE TOOLS ## @@ -378,39 +474,79 @@ let path = "include"; version = "8.0"; sha256 = "128m77k16i7frvk8kifhmxzk7a37m7z1s0bbmja3ywga6sx6v6sq"; - nativeBuildInputs = [ makeMinimal install mandoc groff nbperf rpcgen ]; - extraPaths = [ common.src ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install mandoc groff nbperf rpcgen + ]; + extraPaths = with self; [ common ]; headersOnly = true; noCC = true; - # meta.platforms = lib.platforms.netbsd; - makeFlags = [ "RPCGEN_CPP=${buildPackages.gcc-unwrapped}/bin/cpp" ]; + meta.platforms = lib.platforms.netbsd; + makeFlags = [ "RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp" ]; }; - common = mkDerivation { - path = "common"; - version = "8.0"; - sha256 = "1fsm2b7p7zkhiz523jw75088cq2h39iknp0fp3di9a64bikwbhi1"; - }; + common = fetchNetBSD "common" "8.0" "1fsm2b7p7zkhiz523jw75088cq2h39iknp0fp3di9a64bikwbhi1"; - # The full kernel - sys = mkDerivation { + sys-headers = mkDerivation { + pname = "sys-headers"; path = "sys"; version = "8.0"; sha256 = "123ilg8fqmp69bw6bs6nh98fpi1v2n9lamrzar61p27ji6sj7g0w"; - propagatedBuildInputs = [ include ]; - #meta.platforms = lib.platforms.netbsd; - extraPaths = [ common.src ]; + + CONFIG = "GENERIC"; + + propagatedBuildInputs = with self; [ include ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal install tsort lorder statHook uudecode config genassym + ]; + + postConfigure = '' + pushd arch/$MACHINE/conf + config $CONFIG + popd + ''; + + makeFlags = [ "FIRMWAREDIR=$(out)/libdata/firmware" ]; + hardeningDisable = [ "pic" ]; MKKMOD = "no"; + NIX_CFLAGS_COMPILE = [ "-Wa,--no-warn" ]; + + postBuild = '' + make -C arch/$MACHINE/compile/$CONFIG $makeFlags + ''; + + postInstall = '' + cp arch/$MACHINE/compile/$CONFIG/netbsd $out + ''; + + meta.platforms = lib.platforms.netbsd; + extraPaths = with self; [ common ]; + + installPhase = "includesPhase"; + dontBuild = true; + noCC = true; + }; + + # The full kernel. We do the funny thing of overridding the headers to the + # full kernal and not vice versa to avoid infinite recursion -- the headers + # come earlier in the bootstrap. + sys = self.sys-headers.override { + pname = "sys"; + installPhase = null; + noCC = false; + dontBuild = false; }; headers = symlinkJoin { name = "netbsd-headers-8.0"; - paths = [ include ] ++ map (pkg: pkg.override (_: { - installPhase = "includesPhase"; - dontBuild = true; - noCC = true; - meta.platforms = lib.platforms.all; - })) [ sys libpthread ]; + paths = with self; [ + include + sys-headers + libpthread-headers + ]; + meta.platforms = lib.platforms.netbsd; }; ## ## END HEADERS @@ -423,15 +559,22 @@ let path = "lib/libutil"; version = "8.0"; sha256 = "077syyxd303m4x7avs5nxzk4c9n13d5lyk5aicsacqjvx79qrk3i"; - extraPaths = [ common.src ]; + extraPaths = with self; [ common libc.src sys.src ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + byacc install tsort lorder mandoc statHook + ]; + buildInputs = with self; [ headers ]; + SHLIBINSTALLDIR = "$(out)/lib"; }; libedit = mkDerivation { path = "lib/libedit"; version = "8.0"; sha256 = "0pmqh2mkfp70bwchiwyrkdyq9jcihx12g1awd6alqi9bpr3f9xmd"; - buildInputs = [ libterminfo libcurses ]; - propagatedBuildInputs = [ compat ]; + buildInputs = with self; [ libterminfo libcurses ]; + propagatedBuildInputs = with self; compatIfNeeded; postPatch = '' sed -i '1i #undef bool_t' el.h substituteInPlace config.h \ @@ -449,16 +592,24 @@ let path = "lib/libterminfo"; version = "8.0"; sha256 = "14gp0d6fh6zjnbac2yjhyq5m6rca7gm6q1s9gilhzpdgl9m7vb9r"; - buildInputs = [ compat ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal install tsort lorder mandoc statHook nbperf tic + ]; + buildInputs = with self; compatIfNeeded; + SHLIBINSTALLDIR = "$(out)/lib"; postPatch = '' substituteInPlace term.c --replace /usr/share $out/share substituteInPlace setupterm.c \ --replace '#include <curses.h>' 'void use_env(bool);' ''; + postBuild = '' + make -C $BSDSRCDIR/share/terminfo $makeFlags BINDIR=$out/share + ''; postInstall = '' - make -C $NETBSDSRCDIR/share/terminfo BINDIR=$out/share install + make -C $BSDSRCDIR/share/terminfo $makeFlags BINDIR=$out/share install ''; - extraPaths = [ + extraPaths = with self; [ (fetchNetBSD "share/terminfo" "8.0" "18db0fk1dw691vk6lsm6dksm4cf08g8kdm0gc4052ysdagg2m6sm") ]; }; @@ -467,13 +618,13 @@ let path = "lib/libcurses"; version = "8.0"; sha256 = "0azhzh1910v24dqx45zmh4z4dl63fgsykajrbikx5xfvvmkcq7xs"; - buildInputs = [ libterminfo ]; + buildInputs = with self; [ libterminfo ]; NIX_CFLAGS_COMPILE = [ "-D__scanflike(a,b)=" "-D__va_list=va_list" "-D__warn_references(a,b)=" ] ++ lib.optional stdenv.isDarwin "-D__strong_alias(a,b)="; - propagatedBuildInputs = [ compat ]; + propagatedBuildInputs = with self; compatIfNeeded; MKDOC = "no"; # missing vfontedpr postPatch = lib.optionalString (!stdenv.isDarwin) '' substituteInPlace printw.c \ @@ -495,9 +646,6 @@ let version = "8.0"; sha256 = "03azp5anavhjr15sinjlik9792lyf7w4zmkcihlkksrywhs05axh"; meta.platforms = lib.platforms.netbsd; - postPatch = '' - substituteInPlace rpc/Makefile --replace /usr $out - ''; }; librpcsvc = mkDerivation { @@ -506,6 +654,11 @@ let sha256 = "14ri9w6gdhsm4id5ck133syyvbmkbknfa8w0xkklm726nskhfkj7"; makeFlags = [ "INCSDIR=$(out)/include/rpcsvc" ]; meta.platforms = lib.platforms.netbsd; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install tsort lorder rpcgen statHook + ]; }; librt = mkDerivation { @@ -513,34 +666,56 @@ let version = "8.0"; sha256 = "078qsi4mg1hyyxr1awvjs9b0c2gicg3zw4vl603g1m9vm8gfxw9l"; meta.platforms = lib.platforms.netbsd; + extraPaths = with self; [ common libc.src ]; + postPatch = '' + sed -i 's,/usr\(/include/sys/syscall.h\),${self.headers}\1,g' \ + $BSDSRCDIR/lib/{libc,librt}/sys/Makefile.inc + ''; }; libcrypt = mkDerivation { path = "lib/libcrypt"; version = "8.0"; sha256 = "0siqan1wdqmmhchh2n8w6a8x1abbff8n4yb6jrqxap3hqn8ay54g"; + SHLIBINSTALLDIR = "$(out)/lib"; meta.platforms = lib.platforms.netbsd; }; - libpthread = mkDerivation { + libpthread-headers = mkDerivation { + pname = "libpthread-headers"; path = "lib/libpthread"; version = "8.0"; sha256 = "0pcz61klc3ijf5z2zf8s78nj7bwjfblzjllx7vr4z5qv3m0sdb3j"; + installPhase = "includesPhase"; + dontBuild = true; + noCC = true; meta.platforms = lib.platforms.netbsd; }; + libpthread = self.libpthread-headers.override { + pname = "libpthread"; + installPhase = null; + noCC = false; + dontBuild = false; + buildInputs = with self; [ headers ]; + extraPaths = with self; [ common libc.src sys.src ]; + }; + libresolv = mkDerivation { path = "lib/libresolv"; version = "8.0"; sha256 = "11vpb3p2343wyrhw4v9gwz7i0lcpb9ysmfs9gsx56b5gkgipdy4v"; meta.platforms = lib.platforms.netbsd; + extraPaths = with self; [ libc.src ]; }; libm = mkDerivation { path = "lib/libm"; version = "8.0"; sha256 = "0i22603cgj6n00gn2m446v4kn1pk109qs1g6ylrslmihfmiy2h1d"; + SHLIBINSTALLDIR = "$(out)/lib"; meta.platforms = lib.platforms.netbsd; + extraPaths = with self; [ sys.src ]; }; i18n_module = mkDerivation { @@ -548,6 +723,7 @@ let version = "8.0"; sha256 = "0w6y5v3binm7gf2kn7y9jja8k18rhnyl55cvvfnfipjqdxvxd9jd"; meta.platforms = lib.platforms.netbsd; + extraPaths = with self; [ libc.src ]; }; csu = mkDerivation { @@ -555,9 +731,14 @@ let version = "8.0"; sha256 = "0630lbvz6v4ic13bfg8ccwfhqkgcv76bfdw9f36rfsnwfgpxqsmq"; meta.platforms = lib.platforms.netbsd; - nativeBuildInputs = [ makeMinimal install mandoc groff flex - bison genassym gencat lorder tsort stat ]; - extraPaths = [ sys.src ld_elf_so.src ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install mandoc groff flex + byacc genassym gencat lorder tsort statHook + ]; + buildInputs = with self; [ headers ]; + extraPaths = with self; [ sys.src ld_elf_so.src ]; }; ld_elf_so = mkDerivation { @@ -565,8 +746,12 @@ let version = "8.0"; sha256 = "1jmqpi0kg2daiqnvpwdyfy8rpnszxsm70sxizz0r7wn53xjr5hva"; meta.platforms = lib.platforms.netbsd; + LIBC_PIC = "${stdenv.cc.libc}/lib/libc_pic.a"; + # Hack to prevent a symlink being installed here for compatibility. + SHLINKINSTALLDIR = "/usr/libexec"; USE_FORT = "yes"; - extraPaths = [ libc.src ] ++ libc.extraPaths; + makeFlags = [ "CLIBOBJ=${stdenv.cc.libc}/lib" ]; + extraPaths = with self; [ libc.src ] ++ libc.extraPaths; }; libc = mkDerivation { @@ -575,24 +760,30 @@ let sha256 = "0lgbc58qgn8kwm3l011x1ml1kgcf7jsgq7hbf0hxhlbvxq5bljl3"; USE_FORT = "yes"; MKPROFILE = "no"; - extraPaths = [ common.src i18n_module.src sys.src - ld_elf_so.src libpthread.src libm.src libresolv.src - librpcsvc.src libutil.src librt.src libcrypt.src ]; - buildInputs = [ buildPackages.netbsd.headers csu ]; - nativeBuildInputs = [ makeMinimal install mandoc groff flex - bison genassym gencat lorder tsort stat ]; - NIX_CFLAGS_COMPILE = "-B${csu}/lib"; + extraPaths = with self; [ + common i18n_module.src sys.src + ld_elf_so.src libpthread.src libm.src libresolv.src + librpcsvc.src libutil.src librt.src libcrypt.src + ]; + nativeBuildInputs = with buildPackages.netbsd; [ + bsdSetupHook + makeMinimal + install mandoc groff flex + byacc genassym gencat lorder tsort statHook rpcgen + ]; + buildInputs = with self; [ headers csu ]; + NIX_CFLAGS_COMPILE = "-B${self.csu}/lib"; meta.platforms = lib.platforms.netbsd; SHLIBINSTALLDIR = "$(out)/lib"; NLSDIR = "$(out)/share/nls"; makeFlags = [ "FILESDIR=$(out)/var/db"]; postInstall = '' - pushd ${buildPackages.netbsd.headers} + pushd ${self.headers} find . -type d -exec mkdir -p $out/\{} \; find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; popd - pushd ${csu} + pushd ${self.csu} find . -type d -exec mkdir -p $out/\{} \; find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; popd @@ -601,34 +792,31 @@ let NIX_CFLAGS_COMPILE+=" -I$out/include" NIX_LDFLAGS+=" -L$out/lib" - make -C $NETBSDSRCDIR/lib/libpthread $makeFlags - make -C $NETBSDSRCDIR/lib/libpthread $makeFlags install + make -C $BSDSRCDIR/lib/libpthread $makeFlags + make -C $BSDSRCDIR/lib/libpthread $makeFlags install - make -C $NETBSDSRCDIR/lib/libm $makeFlags - make -C $NETBSDSRCDIR/lib/libm $makeFlags install + make -C $BSDSRCDIR/lib/libm $makeFlags + make -C $BSDSRCDIR/lib/libm $makeFlags install - make -C $NETBSDSRCDIR/lib/libresolv $makeFlags - make -C $NETBSDSRCDIR/lib/libresolv $makeFlags install + make -C $BSDSRCDIR/lib/libresolv $makeFlags + make -C $BSDSRCDIR/lib/libresolv $makeFlags install - make -C $NETBSDSRCDIR/lib/librpcsv $makeFlags - make -C $NETBSDSRCDIR/lib/librpcsv $makeFlags install + make -C $BSDSRCDIR/lib/librpcsvc $makeFlags + make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install - make -C $NETBSDSRCDIR/lib/i18n_module $makeFlags - make -C $NETBSDSRCDIR/lib/i18n_module $makeFlags install + make -C $BSDSRCDIR/lib/i18n_module $makeFlags + make -C $BSDSRCDIR/lib/i18n_module $makeFlags install - make -C $NETBSDSRCDIR/lib/libutil $makeFlags - make -C $NETBSDSRCDIR/lib/libutil $makeFlags install + make -C $BSDSRCDIR/lib/libutil $makeFlags + make -C $BSDSRCDIR/lib/libutil $makeFlags install - make -C $NETBSDSRCDIR/lib/librt $makeFlags - make -C $NETBSDSRCDIR/lib/librt $makeFlags install + make -C $BSDSRCDIR/lib/librt $makeFlags + make -C $BSDSRCDIR/lib/librt $makeFlags install - make -C $NETBSDSRCDIR/lib/libcrypt $makeFlags - make -C $NETBSDSRCDIR/lib/libcrypt $makeFlags install - ''; - postPatch = '' - substituteInPlace sys/Makefile.inc \ - --replace /usr/include/sys/syscall.h ${buildPackages.netbsd.headers}/include/sys/syscall.h + make -C $BSDSRCDIR/lib/libcrypt $makeFlags + make -C $BSDSRCDIR/lib/libcrypt $makeFlags install ''; + inherit (self.librt) postPatch; }; # # END LIBRARIES @@ -664,6 +852,4 @@ let # END MISCELLANEOUS # - }; - -in netbsd +}) diff --git a/pkgs/os-specific/bsd/netbsd/builder.sh b/pkgs/os-specific/bsd/setup-hook.sh index 925001567f7..45babc38d7a 100644 --- a/pkgs/os-specific/bsd/netbsd/builder.sh +++ b/pkgs/os-specific/bsd/setup-hook.sh @@ -1,6 +1,4 @@ -source $stdenv/setup - -# NetBSD makefiles should be able to detect this +# BSD makefiles should be able to detect this # but without they end up using gcc on Darwin stdenv addMakeFlags() { export setOutputFlags= @@ -64,13 +62,12 @@ addMakeFlags() { makeFlags="-j $NIX_BUILD_CORES $makeFlags" } -setNetBSDSourceDir() { +setBSDSourceDir() { # merge together all extra paths # there should be a better way to do this sourceRoot=$PWD/$sourceRoot - export NETBSDSRCDIR=$sourceRoot - export BSDSRCDIR=$NETBSDSRCDIR - export _SRC_TOP_=$NETBSDSRCDIR + export BSDSRCDIR=$sourceRoot + export _SRC_TOP_=$BSDSRCDIR chmod -R u+w $sourceRoot for path in $extraPaths; do cd $path @@ -80,13 +77,14 @@ setNetBSDSourceDir() { done cd $sourceRoot - if [ -d "$NETBSD_PATH" ] - then sourceRoot=$sourceRoot/$NETBSD_PATH + if [ -d "$BSD_PATH" ] + then sourceRoot=$sourceRoot/$BSD_PATH fi } includesPhase() { if [ -z "${skipIncludesPhase:-}" ]; then + runHook preIncludes local flagsArray=( $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} @@ -98,6 +96,7 @@ includesPhase() { moveUsrDir + runHook postIncludes fi } @@ -105,18 +104,17 @@ moveUsrDir() { if [ -d $prefix ]; then # Remove lingering /usr references if [ -d $prefix/usr ]; then - cd $prefix/usr + pushd $prefix/usr find . -type d -exec mkdir -p $out/\{} \; find . \( -type f -o -type l \) -exec mv \{} $out/\{} \; + popd fi find $prefix -type d -empty -delete fi } -postUnpackHooks+=(setNetBSDSourceDir) +postUnpackHooks+=(setBSDSourceDir) preConfigureHooks+=(addMakeFlags) preInstallHooks+=(includesPhase) fixupOutputHooks+=(moveUsrDir) - -genericBuild |