diff options
Diffstat (limited to 'pkgs/os-specific/bsd')
18 files changed, 341 insertions, 84 deletions
diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index eeccd0fa07eab..e288e6d216867 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -40,8 +40,10 @@ makeScopeWithSplicing' { stdenvLibcMinimal = crossLibcStdenv.override (old: { cc = old.cc.override { libc = self.libcMinimal; + noLibc = false; bintools = old.cc.bintools.override { libc = self.libcMinimal; + noLibc = false; sharedLibraryLoader = null; }; }; @@ -98,7 +100,7 @@ makeScopeWithSplicing' { inherit (buildNetbsd) makeMinimal; }; - libcMinimal = self.callPackage ./pkgs/libcMinimal.nix { + libcMinimal = self.callPackage ./pkgs/libcMinimal/package.nix { inherit (self) headers csu; inherit (buildNetbsd) netbsdSetupHook diff --git a/pkgs/os-specific/bsd/netbsd/pkgs/libcMinimal/0001-Allow-building-libc-without-generating-tags.patch b/pkgs/os-specific/bsd/netbsd/pkgs/libcMinimal/0001-Allow-building-libc-without-generating-tags.patch new file mode 100644 index 0000000000000..0c13f650ceba0 --- /dev/null +++ b/pkgs/os-specific/bsd/netbsd/pkgs/libcMinimal/0001-Allow-building-libc-without-generating-tags.patch @@ -0,0 +1,53 @@ +From 62acd447e36d5009d3008e025df72c08690905d5 Mon Sep 17 00:00:00 2001 +From: John Ericson <John.Ericson@Obsidian.Systems> +Date: Thu, 20 Jun 2024 15:48:54 -0400 +Subject: [PATCH] Allow building libc without generating tags + +When bootstrapping from scratch, it is nice to avoid dependencies (like +`ctags`/`genassym`/etc.) that are not strictly needed. + +This makefile change introduces a new `MK_LIBC_TAGS` variable, defaulted +to `yes`, to control whether `make all` / `make install` should +build/install (respectively) the tags. + +The underlying rules for tags can still be run regardless of the choice +of variable. +--- + lib/libc/Makefile | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/lib/libc/Makefile b/lib/libc/Makefile +index f2dab2a090e7..c6aa5e45f959 100644 +--- a/lib/libc/Makefile ++++ b/lib/libc/Makefile +@@ -132,7 +132,12 @@ MKREPRO_SED= -e 's;${NETBSDSRCDIR:C/${REGEX_SPECIALS}/\\\\&/g};/usr/src;' + .endif + + .if !defined(MLIBDIR) && ${RUMPRUN} != "yes" ++realall: ${SRCS} ++ ++.if ${MK_LIBC_TAGS:Uyes} == "yes" + realall: tags ++.endif ++ + tags: ${SRCS} + ${_MKTARGET_CREATE} + -${TOOL_CTAGS} -f ${.TARGET}.tmp -w ${.ALLSRC:M*.c} +@@ -146,11 +151,14 @@ tags: ${SRCS} + .endif + rm -f ${.TARGET}.tmp + ++.if ${MK_LIBC_TAGS:Uyes} == "yes" + FILES= tags + FILESNAME= libc.tags + FILESDIR= /var/db + .endif + ++.endif ++ + + # workaround for I18N stuffs: build singlebyte setlocale() for libc.a, + # multibyte for libc.so. the quirk should be removed when we support +-- +2.42.0 + diff --git a/pkgs/os-specific/bsd/netbsd/pkgs/libcMinimal.nix b/pkgs/os-specific/bsd/netbsd/pkgs/libcMinimal/package.nix index bbab20d53d51e..c1ef1744140ed 100644 --- a/pkgs/os-specific/bsd/netbsd/pkgs/libcMinimal.nix +++ b/pkgs/os-specific/bsd/netbsd/pkgs/libcMinimal/package.nix @@ -28,7 +28,6 @@ mkDerivation { "out" "dev" "man" - "tags" ]; USE_FORT = "yes"; MKPROFILE = "no"; @@ -39,32 +38,44 @@ mkDerivation { "sys" "external/bsd/jemalloc" ]; + + patches = [ + # https://mail-index.netbsd.org/tech-toolchain/2024/06/24/msg004438.html + # + # The patch is vendored because the archive software inlined my + # attachment so I am not sure how to programmatically download it. + ./0001-Allow-building-libc-without-generating-tags.patch + ]; + nativeBuildInputs = [ bsdSetupHook netbsdSetupHook makeMinimal install + tsort + lorder mandoc groff + statHook flex byacc - genassym gencat - lorder - tsort - statHook - rpcgen ]; + buildInputs = [ headers csu ]; + env.NIX_CFLAGS_COMPILE = "-B${csu}/lib -fcommon"; - meta.platforms = lib.platforms.netbsd; + SHLIBINSTALLDIR = "$(out)/lib"; MKPICINSTALL = "yes"; + MK_LIBC_TAGS = "no"; NLSDIR = "$(out)/share/nls"; + makeFlags = defaultMakeFlags ++ [ "FILESDIR=$(out)/var/db" ]; + postInstall = '' pushd ${headers} find include -type d -exec mkdir -p "$dev/{}" ';' @@ -75,11 +86,11 @@ mkDerivation { find lib -type d -exec mkdir -p "$out/{}" ';' find lib '(' -type f -o -type l ')' -exec cp -pr "{}" "$out/{}" ';' popd - - moveToOutput var/db/libc.tags "$tags" ''; postPatch = '' sed -i 's,/usr\(/include/sys/syscall.h\),${headers}\1,g' lib/lib*/sys/Makefile.inc ''; + + meta.platforms = lib.platforms.netbsd; } diff --git a/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix b/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix index 8e0ef5fd1b74e..ad9c9dd2292d2 100644 --- a/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix +++ b/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix @@ -2,7 +2,6 @@ lib, stdenvLibcMinimal, mkDerivation, - headers, libcMinimal, librt, }: diff --git a/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix b/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix index c217f6a7ce465..9ebbaa974c570 100644 --- a/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix +++ b/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix @@ -11,7 +11,6 @@ lorder, mandoc, statHook, - headers, }: mkDerivation { diff --git a/pkgs/os-specific/bsd/openbsd/default.nix b/pkgs/os-specific/bsd/openbsd/default.nix index bfc88f097865f..4db2df57bc262 100644 --- a/pkgs/os-specific/bsd/openbsd/default.nix +++ b/pkgs/os-specific/bsd/openbsd/default.nix @@ -1,5 +1,7 @@ { lib, + crossLibcStdenv, + stdenvNoCC, makeScopeWithSplicing', generateSplicesForMkScope, buildPackages, @@ -19,32 +21,71 @@ makeScopeWithSplicing' { directory = ./pkgs; } // { - libc = self.callPackage ./pkgs/libc/package.nix { + version = "7.5"; + + stdenvLibcMinimal = crossLibcStdenv.override (old: { + cc = old.cc.override { + libc = self.libcMinimal; + noLibc = false; + bintools = old.cc.bintools.override { + libc = self.libcMinimal; + noLibc = false; + sharedLibraryLoader = null; + }; + }; + }); + + makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; }; + + # The manual callPackages below should in principle be unnecessary, but are + # necessary. See note in ../netbsd/default.nix + + include = self.callPackage ./pkgs/include/package.nix { + inherit (buildOpenbsd) makeMinimal; + inherit (buildPackages.netbsd) install rpcgen mtree; + }; + + csu = self.callPackage ./pkgs/csu.nix { + inherit (self) include; + inherit (buildOpenbsd) makeMinimal; + inherit (buildPackages.netbsd) install; + }; + + libcMinimal = self.callPackage ./pkgs/libcMinimal/package.nix { inherit (self) csu include; inherit (buildOpenbsd) makeMinimal; inherit (buildPackages.netbsd) install gencat + tsort rpcgen + ; + }; + + librpcsvc = self.callPackage ./pkgs/librpcsvc.nix { + inherit (buildOpenbsd) openbsdSetupHook makeMinimal lorder; + inherit (buildPackages.netbsd) + install tsort + statHook + rpcgen ; }; - makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; }; + + libutil = self.callPackage ./pkgs/libutil.nix { + inherit (self) libcMinimal; + inherit (buildOpenbsd) openbsdSetupHook makeMinimal lorder; + inherit (buildPackages.netbsd) install tsort statHook; + }; + + lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildPackages.netbsd) install; }; + + make-rules = self.callPackage ./pkgs/make-rules/package.nix { }; + mkDerivation = self.callPackage ./pkgs/mkDerivation.nix { - inherit (buildPackages.netbsd) install; + inherit (buildPackages.netbsd) install tsort; inherit (buildPackages.buildPackages) rsync; }; - include = self.callPackage ./pkgs/include/package.nix { - inherit (buildOpenbsd) makeMinimal; - inherit (buildPackages.netbsd) install rpcgen mtree; - }; - csu = self.callPackage ./pkgs/csu.nix { - inherit (self) include; - inherit (buildOpenbsd) makeMinimal; - inherit (buildPackages.netbsd) install; - }; - make-rules = self.callPackage ./pkgs/make-rules/package.nix { }; - lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildPackages.netbsd) install; }; } ); } diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/libc.nix b/pkgs/os-specific/bsd/openbsd/pkgs/libc.nix new file mode 100644 index 0000000000000..895b82ed53073 --- /dev/null +++ b/pkgs/os-specific/bsd/openbsd/pkgs/libc.nix @@ -0,0 +1,47 @@ +{ + lib, + symlinkJoin, + libcMinimal, + librthread, + libm, + librpcsvc, + libutil, + version, +}: + +symlinkJoin rec { + name = "${pname}-${version}"; + pname = "libc-openbsd"; + inherit version; + + outputs = [ + "out" + "dev" + "man" + ]; + + paths = + lib.concatMap + (p: [ + (lib.getDev p) + (lib.getLib p) + (lib.getMan p) + ]) + [ + libcMinimal + libm + librthread + librpcsvc + libutil + ]; + + postBuild = '' + rm -r "$out/nix-support" + mkdir -p "$man/share/man" + mv "$out/share"/man* "$man/share/man" + rmdir "$out/share" + fixupPhase + ''; + + meta.platforms = lib.platforms.openbsd; +} diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/libc/disable-librebuild.patch b/pkgs/os-specific/bsd/openbsd/pkgs/libcMinimal/disable-librebuild.patch index 58633861a826f..58633861a826f 100644 --- a/pkgs/os-specific/bsd/openbsd/pkgs/libc/disable-librebuild.patch +++ b/pkgs/os-specific/bsd/openbsd/pkgs/libcMinimal/disable-librebuild.patch diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/libc/netbsd-make-to-lower.patch b/pkgs/os-specific/bsd/openbsd/pkgs/libcMinimal/netbsd-make-to-lower.patch index e8d016ceead5a..e8d016ceead5a 100644 --- a/pkgs/os-specific/bsd/openbsd/pkgs/libc/netbsd-make-to-lower.patch +++ b/pkgs/os-specific/bsd/openbsd/pkgs/libcMinimal/netbsd-make-to-lower.patch diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/libc/package.nix b/pkgs/os-specific/bsd/openbsd/pkgs/libcMinimal/package.nix index 1a6b6d06a1936..d8d6cc398e0de 100644 --- a/pkgs/os-specific/bsd/openbsd/pkgs/libc/package.nix +++ b/pkgs/os-specific/bsd/openbsd/pkgs/libcMinimal/package.nix @@ -20,18 +20,16 @@ mkDerivation { noLibc = true; - pname = "libc"; path = "lib/libc"; + pname = "libcMinimal-openbsd"; + outputs = [ + "out" + "dev" + "man" + ]; extraPaths = [ "lib/csu/os-note-elf.h" "sys/arch" - - "lib/libm" - "lib/libpthread" - "lib/librpcsvc" - "lib/librpcsvc" - "lib/librthread" - "lib/libutil" ]; patches = [ @@ -48,12 +46,8 @@ mkDerivation { openbsdSetupHook makeMinimal install - flex - byacc - gencat - rpcgen - ctags tsort + gencat ]; buildInputs = [ @@ -73,49 +67,22 @@ mkDerivation { ) "--undefined-version"; makeFlags = [ - "STRIP=-s" # flag to install, not command "COMPILER_VERSION=clang" "LIBC_TAGS=no" ]; postInstall = '' - symlink_so () { - pushd $out/lib - ln -s "lib$1".so.* "lib$1.so" - popd - } - - symlink_so c - pushd ${include} - find . -type d -exec mkdir -p $out/\{} \; - find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; + find include -type d -exec mkdir -p "$dev/{}" ';' + find include '(' -type f -o -type l ')' -exec cp -pr "{}" "$dev/{}" ';' popd - substituteInPlace $out/include/sys/time.h --replace "defined (_LIBC)" "true" + substituteInPlace "$dev/include/sys/time.h" --replace "defined (_LIBC)" "true" pushd ${csu} - find . -type d -exec mkdir -p $out/\{} \; - find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; + find lib -type d -exec mkdir -p "$out/{}" ';' + find lib '(' -type f -o -type l ')' -exec cp -pr "{}" "$out/{}" ';' popd - - NIX_CFLAGS_COMPILE+=" -B$out/lib" - NIX_CFLAGS_COMPILE+=" -I$out/include" - NIX_LDFLAGS+=" -L$out/lib" - - make -C $BSDSRCDIR/lib/libm $makeFlags - make -C $BSDSRCDIR/lib/libm $makeFlags install - symlink_so m - - make -C $BSDSRCDIR/lib/librthread $makeFlags - make -C $BSDSRCDIR/lib/librthread $makeFlags install - symlink_so pthread - - make -C $BSDSRCDIR/lib/librpcsvc $makeFlags - make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install - symlink_so rpcsv - - make -C $BSDSRCDIR/lib/libutil $makeFlags - make -C $BSDSRCDIR/lib/libutil $makeFlags install - symlink_so util ''; + + meta.platforms = lib.platforms.openbsd; } diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/libm.nix b/pkgs/os-specific/bsd/openbsd/pkgs/libm.nix new file mode 100644 index 0000000000000..bf7e933a092b9 --- /dev/null +++ b/pkgs/os-specific/bsd/openbsd/pkgs/libm.nix @@ -0,0 +1,16 @@ +{ lib, mkDerivation }: + +mkDerivation { + path = "lib/libm"; + + libcMinimal = true; + + outputs = [ + "out" + "man" + ]; + + extraPaths = [ "sys" ]; + + meta.platforms = lib.platforms.openbsd; +} diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/librpcsvc.nix b/pkgs/os-specific/bsd/openbsd/pkgs/librpcsvc.nix new file mode 100644 index 0000000000000..77783a041894d --- /dev/null +++ b/pkgs/os-specific/bsd/openbsd/pkgs/librpcsvc.nix @@ -0,0 +1,38 @@ +{ + lib, + mkDerivation, + bsdSetupHook, + openbsdSetupHook, + makeMinimal, + install, + tsort, + lorder, + rpcgen, + statHook, +}: + +mkDerivation { + path = "lib/librpcsvc"; + + libcMinimal = true; + + outputs = [ + "out" + "dev" + ]; + + nativeBuildInputs = [ + bsdSetupHook + openbsdSetupHook + makeMinimal + install + tsort + lorder + rpcgen + statHook + ]; + + makeFlags = [ "INCSDIR=$(dev)/include/rpcsvc" ]; + + meta.platforms = lib.platforms.openbsd; +} diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/librthread.nix b/pkgs/os-specific/bsd/openbsd/pkgs/librthread.nix new file mode 100644 index 0000000000000..1d42d55290c39 --- /dev/null +++ b/pkgs/os-specific/bsd/openbsd/pkgs/librthread.nix @@ -0,0 +1,29 @@ +{ + lib, + stdenvLibcMinimal, + mkDerivation, + libcMinimal, +}: + +mkDerivation { + path = "lib/librthread"; + + libcMinimal = true; + + outputs = [ + "out" + "dev" + ]; + + makeFlags = [ "LIBCSRCDIR=../libc" ]; + + env.NIX_CFLAGS_COMPILE = "-Wno-error"; + + extraPaths = [ + "lib/libpthread" + libcMinimal.path + #"sys" + ]; + + meta.platforms = lib.platforms.openbsd; +} diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/libutil.nix b/pkgs/os-specific/bsd/openbsd/pkgs/libutil.nix new file mode 100644 index 0000000000000..627fabe8cf2a3 --- /dev/null +++ b/pkgs/os-specific/bsd/openbsd/pkgs/libutil.nix @@ -0,0 +1,40 @@ +{ + lib, + stdenvLibcMinimal, + mkDerivation, + libcMinimal, + bsdSetupHook, + openbsdSetupHook, + makeMinimal, + byacc, + install, + tsort, + lorder, + mandoc, + statHook, +}: + +mkDerivation { + path = "lib/libutil"; + + libcMinimal = true; + + outputs = [ + "out" + "man" + ]; + + nativeBuildInputs = [ + bsdSetupHook + openbsdSetupHook + makeMinimal + byacc + install + tsort + lorder + mandoc + statHook + ]; + + meta.platforms = lib.platforms.openbsd; +} diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/mkDerivation.nix b/pkgs/os-specific/bsd/openbsd/pkgs/mkDerivation.nix index 371c6c58b91fb..a238a326f46d5 100644 --- a/pkgs/os-specific/bsd/openbsd/pkgs/mkDerivation.nix +++ b/pkgs/os-specific/bsd/openbsd/pkgs/mkDerivation.nix @@ -3,6 +3,7 @@ stdenv, stdenvNoCC, crossLibcStdenv, + stdenvLibcMinimal, runCommand, rsync, source, @@ -10,6 +11,8 @@ openbsdSetupHook, makeMinimal, install, + tsort, + lorder, }: lib.makeOverridable ( @@ -20,6 +23,8 @@ lib.makeOverridable ( stdenvNoCC else if attrs.noLibc or false then crossLibcStdenv + else if attrs.libcMinimal or false then + stdenvLibcMinimal else stdenv; in @@ -46,15 +51,12 @@ lib.makeOverridable ( openbsdSetupHook makeMinimal install + tsort + lorder ]; HOST_SH = stdenv'.shell; - makeFlags = [ - "STRIP=-s" # flag to install, not command - "-B" - ]; - MACHINE_ARCH = { # amd64 not x86_64 for this on unlike NetBSD @@ -85,9 +87,6 @@ lib.makeOverridable ( // lib.optionalAttrs stdenv'.hasCC { # TODO should CC wrapper set this? CPP = "${stdenv'.cc.targetPrefix}cpp"; - - # Since STRIP in `makeFlags` has to be a flag, not the binary itself - STRIPBIN = "${stdenv'.cc.bintools.targetPrefix}strip"; } // lib.optionalAttrs (attrs.headersOnly or false) { installPhase = "includesPhase"; diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/openbsdSetupHook/setup-hook.sh b/pkgs/os-specific/bsd/openbsd/pkgs/openbsdSetupHook/setup-hook.sh index 50e79bc2928a9..c0fee276fea3d 100644 --- a/pkgs/os-specific/bsd/openbsd/pkgs/openbsdSetupHook/setup-hook.sh +++ b/pkgs/os-specific/bsd/openbsd/pkgs/openbsdSetupHook/setup-hook.sh @@ -17,5 +17,18 @@ setBinownBingrp() { export BINGRP=$(id -g) } +makeOpenBSDUnversionedLinks() { + [[ -d "$out/lib" ]] || return 0 + pushd "$out/lib" + local l + for l in lib*.so.*; do + l="${l//.so.*/}" + [[ ! -f "$l.so" ]] || continue + ln -s "$l".so.* "$l.so" + done + popd +} + preConfigureHooks+=(addOpenBSDMakeFlags) postPatchHooks+=(fixOpenBSDInstallDirs setBinownBingrp) +preFixupHooks+=(makeOpenBSDUnversionedLinks) diff --git a/pkgs/os-specific/bsd/openbsd/pkgs/source.nix b/pkgs/os-specific/bsd/openbsd/pkgs/source.nix index 359c3f2fbc919..a92dfbd2b2216 100644 --- a/pkgs/os-specific/bsd/openbsd/pkgs/source.nix +++ b/pkgs/os-specific/bsd/openbsd/pkgs/source.nix @@ -1,8 +1,12 @@ -{ fetchcvs }: +{ + lib, + fetchcvs, + version, +}: fetchcvs { cvsRoot = "anoncvs@anoncvs.fr.openbsd.org/cvs"; module = "src"; - tag = "OPENBSD_7_5"; + tag = "OPENBSD_${lib.replaceStrings [ "." ] [ "_" ] version}-RELEASE"; sha256 = "sha256-hzdATew6h/FQV72SWtg3YvUXdPoGjm2SoUS7m3c3fSU="; } diff --git a/pkgs/os-specific/bsd/setup-hook.sh b/pkgs/os-specific/bsd/setup-hook.sh index f9453708ab5db..bc8d372ca8b86 100644 --- a/pkgs/os-specific/bsd/setup-hook.sh +++ b/pkgs/os-specific/bsd/setup-hook.sh @@ -28,7 +28,6 @@ addMakeFlags() { # Definitions passed to share/mk/*.mk. Should be pretty simple - # eventually maybe move it to a configure script. - export DESTDIR= export USETOOLS=never export NOCLANGERROR=yes export NOGCCERROR=yes |