lol

openbsd: init at 7.5

authored by

Ali Abrar and committed by
John Ericson
888dee44 ad6fa01c

+491 -7
+1
lib/systems/default.nix
··· 93 93 else if final.isAndroid then "bionic" 94 94 else if final.isLinux /* default */ then "glibc" 95 95 else if final.isFreeBSD then "fblibc" 96 + else if final.isOpenBSD then "oblibc" 96 97 else if final.isNetBSD then "nblibc" 97 98 else if final.isAvr then "avrlibc" 98 99 else if final.isGhcjs then null
+5
lib/systems/examples.nix
··· 342 342 useLLVM = true; 343 343 }; 344 344 345 + x86_64-openbsd = { 346 + config = "x86_64-unknown-openbsd"; 347 + useLLVM = true; 348 + }; 349 + 345 350 # 346 351 # WASM 347 352 #
+1
lib/systems/parse.nix
··· 469 469 elem (elemAt l 2) [ "wasi" "redox" "mmixware" "ghcjs" "mingw32" ] || 470 470 hasPrefix "freebsd" (elemAt l 2) || 471 471 hasPrefix "netbsd" (elemAt l 2) || 472 + hasPrefix "openbsd" (elemAt l 2) || 472 473 hasPrefix "genode" (elemAt l 2) 473 474 then { 474 475 cpu = elemAt l 0;
+1 -1
pkgs/os-specific/bsd/freebsd/lib/default.nix
··· 14 14 } 15 15 .${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name; 16 16 17 - install-wrapper = builtins.readFile ./install-wrapper.sh; 17 + install-wrapper = builtins.readFile ../../lib/install-wrapper.sh; 18 18 }
pkgs/os-specific/bsd/freebsd/lib/install-wrapper.sh pkgs/os-specific/bsd/lib/install-wrapper.sh
+6 -6
pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
··· 17 17 # HACK: to ensure parent directories exist. This emulates GNU 18 18 # install’s -D option. No alternative seems to exist in BSD install. 19 19 let 20 - binstall = writeShellScript "binstall" '' 21 - set -eu 22 - for last in "$@"; do true; done 23 - mkdir -p $(dirname $last) 24 - @out@/bin/xinstall "$@" 25 - ''; 20 + binstall = writeShellScript "binstall" ( 21 + builtins.readFile ../../../lib/install-wrapper.sh 22 + + '' 23 + @out@/bin/xinstall "''${args[@]}" 24 + '' 25 + ); 26 26 in 27 27 mkDerivation { 28 28 path = "usr.bin/xinstall";
+49
pkgs/os-specific/bsd/openbsd/default.nix
··· 1 + { 2 + stdenv, 3 + lib, 4 + stdenvNoCC, 5 + makeScopeWithSplicing', 6 + generateSplicesForMkScope, 7 + pkgs, 8 + buildPackages, 9 + netbsd, 10 + }: 11 + 12 + makeScopeWithSplicing' { 13 + otherSplices = generateSplicesForMkScope "openbsd"; 14 + f = ( 15 + self: 16 + lib.packagesFromDirectoryRecursive { 17 + callPackage = self.callPackage; 18 + directory = ./pkgs; 19 + } 20 + // { 21 + libc = self.callPackage ./pkgs/libc/package.nix { 22 + inherit (self) csu include lorder; 23 + inherit (buildPackages.openbsd) makeMinimal; 24 + inherit (buildPackages.netbsd) 25 + install 26 + gencat 27 + rpcgen 28 + tsort 29 + ; 30 + }; 31 + makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; }; 32 + mkDerivation = self.callPackage ./pkgs/mkDerivation.nix { 33 + inherit stdenv; 34 + inherit (buildPackages.netbsd) install; 35 + }; 36 + include = self.callPackage ./pkgs/include/package.nix { 37 + inherit (buildPackages.openbsd) makeMinimal; 38 + inherit (buildPackages.netbsd) install rpcgen mtree; 39 + }; 40 + csu = self.callPackage ./pkgs/csu.nix { 41 + inherit (self) include; 42 + inherit (buildPackages.openbsd) makeMinimal; 43 + inherit (buildPackages.netbsd) install; 44 + }; 45 + make-rules = self.callPackage ./pkgs/make-rules/package.nix { }; 46 + lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildPackages.netbsd) install; }; 47 + } 48 + ); 49 + }
+22
pkgs/os-specific/bsd/openbsd/pkgs/csu.nix
··· 1 + { 2 + lib, 3 + mkDerivation, 4 + bsdSetupHook, 5 + openbsdSetupHook, 6 + makeMinimal, 7 + install, 8 + include, 9 + }: 10 + 11 + mkDerivation { 12 + path = "lib/csu"; 13 + nativeBuildInputs = [ 14 + bsdSetupHook 15 + openbsdSetupHook 16 + makeMinimal 17 + install 18 + ]; 19 + buildInputs = [ include ]; 20 + meta.platforms = lib.platforms.openbsd; 21 + extraPaths = [ "libexec/ld.so" ]; 22 + }
+57
pkgs/os-specific/bsd/openbsd/pkgs/include/package.nix
··· 1 + { 2 + lib, 3 + mkDerivation, 4 + makeMinimal, 5 + bsdSetupHook, 6 + openbsdSetupHook, 7 + install, 8 + rpcgen, 9 + mtree, 10 + pax, 11 + buildPackages, 12 + }: 13 + mkDerivation { 14 + path = "include"; 15 + noCC = true; 16 + 17 + extraPaths = [ 18 + "lib" 19 + #"sys" 20 + "sys/arch" 21 + # LDIRS from the mmakefile 22 + "sys/crypto" 23 + "sys/ddb" 24 + "sys/dev" 25 + "sys/isofs" 26 + "sys/miscfs" 27 + "sys/msdosfs" 28 + "sys/net" 29 + "sys/netinet" 30 + "sys/netinet6" 31 + "sys/netmpls" 32 + "sys/net80211" 33 + "sys/nfs" 34 + "sys/ntfs" 35 + "sys/scsi" 36 + "sys/sys" 37 + "sys/ufs" 38 + "sys/uvm" 39 + ]; 40 + 41 + nativeBuildInputs = [ 42 + bsdSetupHook 43 + install 44 + makeMinimal 45 + mtree 46 + openbsdSetupHook 47 + pax 48 + rpcgen 49 + ]; 50 + 51 + makeFlags = [ 52 + "RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp" 53 + "-B" 54 + ]; 55 + 56 + headersOnly = true; 57 + }
+12
pkgs/os-specific/bsd/openbsd/pkgs/libc/disable-librebuild.patch
··· 1 + diff --git a/lib/libc/Makefile b/lib/libc/Makefile 2 + index 4bb4b67fcbb..1c8a8e08e60 100644 3 + --- a/lib/libc/Makefile 4 + +++ b/lib/libc/Makefile 5 + @@ -6,7 +6,6 @@ 6 + .include <bsd.own.mk> 7 + 8 + LIB=c 9 + -LIBREBUILD=y 10 + CLEANFILES+=tags Symbols.map 11 + CFLAGS+=-Wimplicit 12 + #CFLAGS+=-Werror
+16
pkgs/os-specific/bsd/openbsd/pkgs/libc/netbsd-make-to-lower.patch
··· 1 + NetBSD's make uses `${variable:tl}` not `${variable:L}`. 2 + 3 + diff --git a/lib/libc/Makefile b/lib/libc/Makefile 4 + index 4bb4b67fcbb..ffb35c196ea 100644 5 + --- a/lib/libc/Makefile 6 + +++ b/lib/libc/Makefile 7 + @@ -11,8 +11,8 @@ CLEANFILES+=tags Symbols.map 8 + CFLAGS+=-Wimplicit 9 + #CFLAGS+=-Werror 10 + LDADD=-nostdlib 11 + -.if ${COMPILER_VERSION:L} == "clang" 12 + +.if ${COMPILER_VERSION:tl} == "clang" 13 + LDADD+=-lcompiler_rt 14 + .else 15 + LDADD+=-lgcc 16 + .endif
+120
pkgs/os-specific/bsd/openbsd/pkgs/libc/package.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + mkDerivation, 5 + bsdSetupHook, 6 + openbsdSetupHook, 7 + makeMinimal, 8 + install, 9 + flex, 10 + byacc, 11 + gencat, 12 + rpcgen, 13 + lorder, 14 + csu, 15 + include, 16 + ctags, 17 + tsort, 18 + llvmPackages, 19 + fetchpatch, 20 + }: 21 + 22 + mkDerivation rec { 23 + pname = "libc"; 24 + path = "lib/libc"; 25 + extraPaths = [ 26 + "lib/csu/os-note-elf.h" 27 + "sys/arch" 28 + 29 + "lib/libm" 30 + "lib/libpthread" 31 + "lib/librpcsvc" 32 + "lib/librpcsvc" 33 + "lib/librthread" 34 + "lib/libutil" 35 + ]; 36 + 37 + patches = [ 38 + ./netbsd-make-to-lower.patch 39 + ./disable-librebuild.patch 40 + (fetchpatch { 41 + url = "https://marc.info/?l=openbsd-tech&m=171575286706032&q=raw"; 42 + sha256 = "sha256-2fqabJZLUvXUIWe5WZ4NrTOwgQCXqH49Wo0hAPu5lu0="; 43 + }) 44 + ]; 45 + 46 + nativeBuildInputs = [ 47 + bsdSetupHook 48 + openbsdSetupHook 49 + makeMinimal 50 + install 51 + flex 52 + byacc 53 + gencat 54 + rpcgen 55 + ctags 56 + lorder 57 + tsort 58 + ]; 59 + 60 + buildInputs = [ 61 + include 62 + csu 63 + ]; 64 + 65 + env.NIX_CFLAGS_COMPILE = builtins.toString [ 66 + "-B${csu}/lib" 67 + "-Wno-error" 68 + ]; 69 + 70 + # Suppress lld >= 16 undefined version errors 71 + # https://github.com/freebsd/freebsd-src/commit/2ba84b4bcdd6012e8cfbf8a0d060a4438623a638 72 + env.NIX_LDFLAGS = lib.optionalString (stdenv.hostPlatform.linker == "lld") "--undefined-version"; 73 + 74 + makeFlags = [ 75 + "STRIP=-s" # flag to install, not command 76 + "COMPILER_VERSION=clang" 77 + "LIBC_TAGS=no" 78 + ]; 79 + 80 + postInstall = '' 81 + symlink_so () { 82 + pushd $out/lib 83 + ln -s "lib$1".so.* "lib$1.so" 84 + popd 85 + } 86 + 87 + symlink_so c 88 + 89 + pushd ${include} 90 + find . -type d -exec mkdir -p $out/\{} \; 91 + find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; 92 + popd 93 + substituteInPlace $out/include/sys/time.h --replace "defined (_LIBC)" "true" 94 + 95 + pushd ${csu} 96 + find . -type d -exec mkdir -p $out/\{} \; 97 + find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; 98 + popd 99 + 100 + NIX_CFLAGS_COMPILE+=" -B$out/lib" 101 + NIX_CFLAGS_COMPILE+=" -I$out/include" 102 + NIX_LDFLAGS+=" -L$out/lib" 103 + 104 + make -C $BSDSRCDIR/lib/libm $makeFlags 105 + make -C $BSDSRCDIR/lib/libm $makeFlags install 106 + symlink_so m 107 + 108 + make -C $BSDSRCDIR/lib/librthread $makeFlags 109 + make -C $BSDSRCDIR/lib/librthread $makeFlags install 110 + symlink_so pthread 111 + 112 + make -C $BSDSRCDIR/lib/librpcsvc $makeFlags 113 + make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install 114 + symlink_so rpcsv 115 + 116 + make -C $BSDSRCDIR/lib/libutil $makeFlags 117 + make -C $BSDSRCDIR/lib/libutil $makeFlags install 118 + symlink_so util 119 + ''; 120 + }
+20
pkgs/os-specific/bsd/openbsd/pkgs/lorder.nix
··· 1 + { 2 + lib, 3 + mkDerivation, 4 + bsdSetupHook, 5 + openbsdSetupHook, 6 + makeMinimal, 7 + install, 8 + }: 9 + 10 + mkDerivation { 11 + path = "usr.bin/lorder"; 12 + nativeBuildInputs = [ 13 + bsdSetupHook 14 + openbsdSetupHook 15 + makeMinimal 16 + install 17 + ]; 18 + 19 + meta.platforms = lib.platforms.unix; 20 + }
+15
pkgs/os-specific/bsd/openbsd/pkgs/make-rules/netbsd-make-sinclude.patch
··· 1 + NetBSD make prefers `.-include` to `sinclude` (without a dot) 2 + 3 + diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk 4 + index 7019adb57f7..277064eb5c2 100644 5 + --- a/share/mk/bsd.dep.mk 6 + +++ b/share/mk/bsd.dep.mk 7 + @@ -11,7 +11,7 @@ depend: 8 + # catch22: don't include potentially bogus files we are going to clean 9 + . if !(make(clean) || make(cleandir) || make(obj)) 10 + . for o in ${DEPS} 11 + - sinclude $o 12 + +. -include "$o" 13 + . endfor 14 + . endif 15 + .endif
+36
pkgs/os-specific/bsd/openbsd/pkgs/make-rules/package.nix
··· 1 + { 2 + fetchpatch, 3 + lib, 4 + mkDerivation, 5 + stdenv, 6 + }: 7 + 8 + mkDerivation { 9 + path = "share/mk"; 10 + noCC = true; 11 + 12 + buildInputs = [ ]; 13 + nativeBuildInputs = [ ]; 14 + 15 + dontBuild = true; 16 + 17 + patches = [ 18 + (fetchpatch { 19 + url = "https://marc.info/?l=openbsd-tech&m=171575284906018&q=raw"; 20 + sha256 = "sha256-bigxJGbaf9mCmFXxLVzQpnUUaEMMDfF3eZkTXVzd6B8="; 21 + }) 22 + ./netbsd-make-sinclude.patch 23 + ]; 24 + 25 + postPatch = '' 26 + sed -i -E \ 27 + -e 's|/usr/lib|\$\{LIBDIR\}|' \ 28 + share/mk/bsd.prog.mk 29 + ''; 30 + 31 + installPhase = '' 32 + cp -r share/mk $out 33 + ''; 34 + 35 + meta.platforms = lib.platforms.unix; 36 + }
+91
pkgs/os-specific/bsd/openbsd/pkgs/mkDerivation.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + stdenvNoCC, 5 + runCommand, 6 + rsync, 7 + source, 8 + bsdSetupHook, 9 + openbsdSetupHook, 10 + makeMinimal, 11 + install, 12 + }: 13 + 14 + lib.makeOverridable ( 15 + attrs: 16 + let 17 + stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv; 18 + in 19 + stdenv'.mkDerivation ( 20 + rec { 21 + pname = "${attrs.pname or (baseNameOf attrs.path)}-openbsd"; 22 + version = "0"; 23 + src = runCommand "${pname}-filtered-src" { nativeBuildInputs = [ rsync ]; } '' 24 + for p in ${lib.concatStringsSep " " ([ attrs.path ] ++ attrs.extraPaths or [ ])}; do 25 + set -x 26 + path="$out/$p" 27 + mkdir -p "$(dirname "$path")" 28 + src_path="${source}/$p" 29 + if [[ -d "$src_path" ]]; then src_path+=/; fi 30 + rsync --chmod="+w" -r "$src_path" "$path" 31 + set +x 32 + done 33 + ''; 34 + 35 + extraPaths = [ ]; 36 + 37 + nativeBuildInputs = [ 38 + bsdSetupHook 39 + openbsdSetupHook 40 + makeMinimal 41 + install 42 + ]; 43 + 44 + HOST_SH = stdenv'.shell; 45 + 46 + # Since STRIP below is the flag 47 + STRIPBIN = "${stdenv.cc.bintools.targetPrefix}strip"; 48 + 49 + makeFlags = [ 50 + "STRIP=-s" # flag to install, not command 51 + "-B" 52 + ]; 53 + 54 + MACHINE_ARCH = 55 + { 56 + # amd64 not x86_64 for this on unlike NetBSD 57 + x86_64 = "amd64"; 58 + aarch64 = "arm64"; 59 + i486 = "i386"; 60 + i586 = "i386"; 61 + i686 = "i386"; 62 + } 63 + .${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name; 64 + 65 + MACHINE = MACHINE_ARCH; 66 + 67 + MACHINE_CPU = MACHINE_ARCH; 68 + 69 + MACHINE_CPUARCH = MACHINE_ARCH; 70 + 71 + COMPONENT_PATH = attrs.path or null; 72 + 73 + strictDeps = true; 74 + 75 + meta = with lib; { 76 + maintainers = with maintainers; [ ericson2314 ]; 77 + platforms = platforms.openbsd; 78 + license = licenses.bsd2; 79 + }; 80 + } 81 + // lib.optionalAttrs stdenv'.hasCC { 82 + # TODO should CC wrapper set this? 83 + CPP = "${stdenv'.cc.targetPrefix}cpp"; 84 + } 85 + // lib.optionalAttrs (attrs.headersOnly or false) { 86 + installPhase = "includesPhase"; 87 + dontBuild = true; 88 + } 89 + // attrs 90 + ) 91 + )
+3
pkgs/os-specific/bsd/openbsd/pkgs/openbsdSetupHook/package.nix
··· 1 + { makeSetupHook }: 2 + 3 + makeSetupHook { name = "openbsd-setup-hook"; } ./setup-hook.sh
+21
pkgs/os-specific/bsd/openbsd/pkgs/openbsdSetupHook/setup-hook.sh
··· 1 + addOpenBSDMakeFlags() { 2 + makeFlags="INCSDIR=${!outputDev}/include $makeFlags" 3 + makeFlags="MANDIR=${!outputMan}/share/man $makeFlags" 4 + } 5 + 6 + fixOpenBSDInstallDirs() { 7 + find "$BSDSRCDIR" -name Makefile -exec \ 8 + sed -i -E \ 9 + -e 's|/usr/include|${INCSDIR}|' \ 10 + -e 's|/usr/bin|${BINDIR}|' \ 11 + -e 's|/usr/lib|${LIBDIR}|' \ 12 + {} \; 13 + } 14 + 15 + setBinownBingrp() { 16 + export BINOWN=$(id -u) 17 + export BINGRP=$(id -g) 18 + } 19 + 20 + preConfigureHooks+=(addOpenBSDMakeFlags) 21 + postPatchHooks+=(fixOpenBSDInstallDirs setBinownBingrp)
+8
pkgs/os-specific/bsd/openbsd/pkgs/source.nix
··· 1 + { fetchcvs }: 2 + 3 + fetchcvs { 4 + cvsRoot = "anoncvs@anoncvs.fr.openbsd.org/cvs"; 5 + module = "src"; 6 + tag = "OPENBSD_7_5"; 7 + sha256 = "sha256-hzdATew6h/FQV72SWtg3YvUXdPoGjm2SoUS7m3c3fSU="; 8 + }
+7
pkgs/top-level/all-packages.nix
··· 16284 16284 choose = platform: 16285 16285 /**/ if platform.isDarwin then 16 16286 16286 else if platform.isFreeBSD then 16 16287 + else if platform.isOpenBSD then 18 16287 16288 else if platform.isAndroid then 12 16288 16289 else if platform.isLinux then 17 16289 16290 else if platform.isWasm then 16 ··· 21019 21020 then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries 21020 21021 else targetPackages.darwin.LibsystemCross or (throw "don't yet have a `targetPackages.darwin.LibsystemCross for ${stdenv.targetPlatform.config}`") 21021 21022 else if name == "fblibc" then targetPackages.freebsdCross.libc or freebsdCross.libc 21023 + else if name == "oblibc" then targetPackages.openbsdCross.libc or openbsdCross.libc 21022 21024 else if name == "nblibc" then targetPackages.netbsdCross.libc or netbsdCross.libc 21023 21025 else if name == "wasilibc" then targetPackages.wasilibc or wasilibc 21024 21026 else if name == "relibc" then targetPackages.relibc or relibc ··· 40741 40743 40742 40744 netbsd = callPackage ../os-specific/bsd/netbsd { }; 40743 40745 netbsdCross = callPackage ../os-specific/bsd/netbsd { 40746 + stdenv = crossLibcStdenv; 40747 + }; 40748 + 40749 + openbsd = callPackage ../os-specific/bsd/openbsd { }; 40750 + openbsdCross = callPackage ../os-specific/bsd/openbsd { 40744 40751 stdenv = crossLibcStdenv; 40745 40752 }; 40746 40753