From a026242e4a2353d33dea47c09617f0988eae779f Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 26 Apr 2018 12:24:45 -0500 Subject: [PATCH 01/14] netbsd: remove broken attributes --- pkgs/os-specific/bsd/netbsd/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 42633232c71..e382fcbb9f0 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -287,7 +287,7 @@ let }; in rec { - inherit compat libc libutil install make mtree netBSDDerivation; + inherit compat install make netBSDDerivation; getent = netBSDDerivation { path = "usr.bin/getent"; From 4539f1f2f72ab4d95642506c4481379f09d2699c Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 26 Apr 2018 12:29:58 -0500 Subject: [PATCH 02/14] netbsd: install db.h to compat --- pkgs/os-specific/bsd/netbsd/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index e382fcbb9f0..387d0cd270e 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -196,6 +196,7 @@ let 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/include/vis.h $out/include/vis.h + install -D $NETBSDSRCDIR/include/db.h $out/include/db.h ''; extraPaths = [ libc.src libutil.src (fetchNetBSD "include" "7.1.2" "1vc58xrhrp202biiv1chhlh0jwnjr7k3qq91pm46k6v5j95j0qwp") From e521bada21b18bcb623c549b5d153d5612afbf96 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 26 Apr 2018 12:31:06 -0500 Subject: [PATCH 03/14] netbsd: propagate compat --- pkgs/os-specific/bsd/netbsd/default.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 387d0cd270e..03d93f3d908 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -288,7 +288,7 @@ let }; in rec { - inherit compat install make netBSDDerivation; + inherit compat install netBSDDerivation; getent = netBSDDerivation { path = "usr.bin/getent"; @@ -309,6 +309,7 @@ in rec { sha256 = "01d4fpxvz1pgzfk5xznz5dcm0x0gdzwcsfm1h3d0xc9kc6hj2q77"; version = "7.1.2"; nativeBuildInputs = [ ]; + propagatedBuildInputs = [ compat ]; extraPaths = [ (fetchNetBSD "lib/libc/gen/fts.c" "7.1.2" "1yfd2liypj6xky2h0mgxi5lgpflmkkg4zf3ii3apz5cf8jq9gmn9") (fetchNetBSD "lib/libc/include/namespace.h" "7.1.2" "0kwd4v8y0mfjhmwplsk52pvzbcpvpp2qy2g8c0jmfraam63q6q1y") @@ -358,7 +359,8 @@ in rec { libedit = netBSDDerivation { path = "lib/libedit"; - buildInputs = [ compat libterminfo ]; + buildInputs = [ libterminfo libcurses ]; + propagatedBuildInputs = [ compat ]; patchPhase = '' sed -i '1i #undef bool_t' el.h ''; @@ -380,7 +382,8 @@ in rec { path = "lib/libcurses"; version = "7.1.2"; sha256 = "04djah9dadzw74nswn0xydkxn900kav8xdvxlxdl50nbrynxg9yf"; - buildInputs = [ compat libterminfo ]; + buildInputs = [ libterminfo ]; + propagatedBuildInputs = [ compat ]; MKDOC = "no"; # missing vfontedpr }; From 968e8a1099859bf41cc34ca453bda897cdb8380c Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 26 Apr 2018 17:57:53 +0000 Subject: [PATCH 04/14] netbsd: fix getent with musl --- pkgs/os-specific/bsd/netbsd/default.nix | 58 +++++++++++++------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 03d93f3d908..f64c36932e3 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -25,6 +25,7 @@ let "-D__warn_references(a,b)=" "-D__strong_alias(a,b)=" "-D__va_list=va_list" + "-D__scanflike(a,b)=" ]; # Definitions passed to share/mk/*.mk. Should be pretty simple - @@ -210,9 +211,36 @@ let version = "7.1.2"; sha256 = "0nzhyh714m19h61m45gzc5dszkbafp5iaphbp5mza6w020fzf2y8"; extraPaths = [ mtree.src make.src ]; - nativeBuildInputs = [ makeMinimal mandoc groff compat ]; + nativeBuildInputs = [ makeMinimal mandoc groff ]; + buildInputs = [ compat fts ]; RENAME = "-D"; }; + + fts = netBSDDerivation { + pname = "fts"; + path = "include/fts.h"; + sha256 = "01d4fpxvz1pgzfk5xznz5dcm0x0gdzwcsfm1h3d0xc9kc6hj2q77"; + version = "7.1.2"; + nativeBuildInputs = [ ]; + propagatedBuildInputs = [ compat ]; + extraPaths = [ + (fetchNetBSD "lib/libc/gen/fts.c" "7.1.2" "1yfd2liypj6xky2h0mgxi5lgpflmkkg4zf3ii3apz5cf8jq9gmn9") + (fetchNetBSD "lib/libc/include/namespace.h" "7.1.2" "0kwd4v8y0mfjhmwplsk52pvzbcpvpp2qy2g8c0jmfraam63q6q1y") + (fetchNetBSD "lib/libc/gen/fts.3" "7.1.2" "1asxw0n3fhjdadwkkq3xplfgqgl3q32w1lyrvbakfa3gs0wz5zc1") + ]; + buildPhase = '' + cc -c -Iinclude -Ilib/libc/include lib/libc/gen/fts.c \ + -o lib/libc/gen/fts.o + ar -rsc libfts.a lib/libc/gen/fts.o + ''; + installPhase = '' + install -D lib/libc/gen/fts.3 $out/share/man/man3/fts.3 + install -D include/fts.h $out/include/fts.h + install -D lib/libc/include/namespace.h $out/include/namespace.h + install -D libfts.a $out/lib/libfts.a + ''; + setupHook = ./fts-setup-hook.sh; + }; # END BOOTSTRAPPING libutil = netBSDDerivation { @@ -288,7 +316,7 @@ let }; in rec { - inherit compat install netBSDDerivation; + inherit compat install netBSDDerivation fts; getent = netBSDDerivation { path = "usr.bin/getent"; @@ -303,32 +331,6 @@ in rec { version = "7.1.2"; }; - fts = netBSDDerivation { - pname = "fts"; - path = "include/fts.h"; - sha256 = "01d4fpxvz1pgzfk5xznz5dcm0x0gdzwcsfm1h3d0xc9kc6hj2q77"; - version = "7.1.2"; - nativeBuildInputs = [ ]; - propagatedBuildInputs = [ compat ]; - extraPaths = [ - (fetchNetBSD "lib/libc/gen/fts.c" "7.1.2" "1yfd2liypj6xky2h0mgxi5lgpflmkkg4zf3ii3apz5cf8jq9gmn9") - (fetchNetBSD "lib/libc/include/namespace.h" "7.1.2" "0kwd4v8y0mfjhmwplsk52pvzbcpvpp2qy2g8c0jmfraam63q6q1y") - (fetchNetBSD "lib/libc/gen/fts.3" "7.1.2" "1asxw0n3fhjdadwkkq3xplfgqgl3q32w1lyrvbakfa3gs0wz5zc1") - ]; - buildPhase = '' - cc -c -Iinclude -Ilib/libc/include lib/libc/gen/fts.c \ - -o lib/libc/gen/fts.o - ar -rsc libfts.a lib/libc/gen/fts.o - ''; - installPhase = '' - install -D lib/libc/gen/fts.3 $out/share/man/man3/fts.3 - install -D include/fts.h $out/include/fts.h - install -D lib/libc/include/namespace.h $out/include/namespace.h - install -D libfts.a $out/lib/libfts.a - ''; - setupHook = ./fts-setup-hook.sh; - }; - games = netBSDDerivation { path = "games"; sha256 = "04wjsang8f8kxsifiayklbxaaxmm3vx9rfr91hfbxj4hk8gkqzy1"; From ddc23593e1885e04663fe735e29c4f45978a6d87 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 27 Apr 2018 01:59:36 +0000 Subject: [PATCH 05/14] netbsd: fix links installer --- pkgs/os-specific/bsd/netbsd/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index f64c36932e3..f0220fc05d2 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -280,6 +280,9 @@ let --replace '-o ''${DEBUGOWN} -g ''${DEBUGGRP}' "" substituteInPlace $NETBSDSRCDIR/share/mk/bsd.doc.mk \ --replace '-o ''${DOCOWN} -g ''${DOCGRP}' "" + substituteInPlace $NETBSDSRCDIR/share/mk/bsd.links.mk \ + --replace '-o ''${LINKSOWN_''${.ALLSRC:T}:U''${LINKSOWN}}' "" \ + --replace '-g ''${LINKSGRP_''${.ALLSRC:T}:U''${LINKSGRP}}' "" substituteInPlace $NETBSDSRCDIR/share/mk/bsd.man.mk \ --replace '-o ''${MANOWN} -g ''${MANGRP}' "" substituteInPlace $NETBSDSRCDIR/share/mk/bsd.files.mk \ @@ -338,6 +341,7 @@ in rec { patchPhase = '' sed -i '1i #include ' adventure/save.c ''; + buildInputs = [ compat libcurses ]; }; who = netBSDDerivation { From 73d5006abcf983d91f31f1962ec1a7649fd23981 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 27 Apr 2018 07:05:56 +0000 Subject: [PATCH 06/14] netbsd: more cleanup --- pkgs/os-specific/bsd/netbsd/default.nix | 130 ++++++++++++++++++------ 1 file changed, 100 insertions(+), 30 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index f0220fc05d2..67ad3687c2c 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -15,19 +15,11 @@ let extraPaths = [ ]; - nativeBuildInputs = [ makeMinimal mandoc groff install yacc flex ]; + nativeBuildInputs = [ makeMinimal mandoc groff install stat + yacc flex tsort lorder ]; buildInputs = [ compat ]; installFlags = [ "includes" ]; - # These should be coverd in nbcompat, but are missing, sadly - NIX_CFLAGS_COMPILE = [ - "-D__noinline=" - "-D__warn_references(a,b)=" - "-D__strong_alias(a,b)=" - "-D__va_list=va_list" - "-D__scanflike(a,b)=" - ]; - # Definitions passed to share/mk/*.mk. Should be pretty simple - # eventually maybe move it to a configure script. DESTDIR = "$(out)"; @@ -46,8 +38,12 @@ let LIBUTIL=""; LIBSSL = ""; LIBCRYPTO = ""; + LIBCRYPT = ""; LIBCURSES = ""; + LIBTERMINFO = ""; + LIBM = ""; "LIBDO.terminfo" = "_external"; + "LIBDO.curses" = "_external"; _GCC_CRTBEGIN = ""; _GCC_CRTBEGINS = ""; _GCC_CRTEND = ""; @@ -75,7 +71,6 @@ let # not using bsd binutils SHLIB_WARNTEXTREL = "no"; SHLIB_MKMAP = "no"; - OBJCOPY = "true"; PRESERVE = "-p"; MACHINE_ARCH = hostPlatform.parsed.cpu.name; @@ -85,9 +80,8 @@ let # but without they end up using gcc on Darwin stdenv preConfigure = '' export HAVE_${if stdenv.cc.isGNU then "GCC" else "LLVM"}=${lib.head (lib.splitString "." (lib.getVersion stdenv.cc.cc))} - '' + lib.optionalString (!builtins.hasAttr "nativeBuildInputs" attrs) '' - # hack until #38657 is fixed - export PATH=${install}/bin:$PATH + # Parallel building. Needs the space. + export makeFlags+=" -j $NIX_BUILD_CORES" ''; postUnpack = '' @@ -110,12 +104,14 @@ let fi ''; - # need to create directories for xinstall to work + # Need to create directories for xinstall to work. Unused ones + # will be removed in the postInstall. preInstall = '' mkdir -p $out$BINDIR $out$LIBDIR $out$INFODIR \ - $out$DOCDIR $out$LOCALEDIR + $out$DOCDIR $out$LOCALEDIR $out/usr/games for i in 1 2 3 4 5 6 7 8 9; do - mkdir -p $out$MANDIR/man$i $out$MANDIR/html$i $out$DOCDIR/reference/ref$i + mkdir -p $out$MANDIR/man$i $out$MANDIR/html$i \ + $out$DOCDIR/reference/ref$i done mkdir -p $out/usr/include ''; @@ -126,7 +122,6 @@ let cd $out/usr find . -type d -exec mkdir -p $out/\{} \; find . -type f -exec mv \{} $out/\{} \; - find . -type d -delete fi find $out -type d -empty -delete @@ -147,8 +142,6 @@ let buildInputs = []; nativeBuildInputs = []; - NIX_CFLAGS_COMPILE = ""; - NIX_LDFLAGS = ""; patchPhase = '' patchShebangs configure @@ -174,8 +167,6 @@ let # override defaults to prevent infinite recursion nativeBuildInputs = [ makeMinimal ]; buildInputs = [ zlib ]; - NIX_CFLAGS_COMPILE = ""; - NIX_LDFLAGS = ""; # temporarily use gnuinstall for bootstrapping # bsdinstall will be built later @@ -198,6 +189,19 @@ let install -D $NETBSDSRCDIR/sys/sys/sha2.h $out/include/sha2.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 + + # Remove lingering /usr references + if [ -d $out/usr ]; then + cd $out/usr + find . -type d -exec mkdir -p $out/\{} \; + find . -type f -exec mv \{} $out/\{} \; + fi + + find $out -type d -empty -delete ''; extraPaths = [ libc.src libutil.src (fetchNetBSD "include" "7.1.2" "1vc58xrhrp202biiv1chhlh0jwnjr7k3qq91pm46k6v5j95j0qwp") @@ -241,6 +245,27 @@ let ''; setupHook = ./fts-setup-hook.sh; }; + + stat = netBSDDerivation { + path = "usr.bin/stat"; + version = "7.1.2"; + sha256 = "0z4r96id2r4cfy443rw2s1n52n186xm0lqvs8s3qjf4314z7r7yh"; + nativeBuildInputs = [ makeMinimal mandoc groff install ]; + }; + + tsort = netBSDDerivation { + path = "usr.bin/tsort"; + version = "7.1.2"; + sha256 = "1dqvf9gin29nnq3c4byxc7lfd062pg7m84843zdy6n0z63hnnwiq"; + nativeBuildInputs = [ makeMinimal mandoc groff install ]; + }; + + lorder = netBSDDerivation { + path = "usr.bin/lorder"; + version = "7.1.2"; + sha256 = "0rjf9blihhm0n699vr2bg88m4yjhkbxh6fxliaay3wxkgnydjwn2"; + nativeBuildInputs = [ makeMinimal mandoc groff install ]; + }; # END BOOTSTRAPPING libutil = netBSDDerivation { @@ -267,7 +292,7 @@ let version = "7.1.2"; patchPhase = '' # make needs this to pick up our sys make files - NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\"" + export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\"" # can't set owner or group in Nix build # maybe there is a better way to trick it? @@ -293,13 +318,10 @@ let substituteInPlace $NETBSDSRCDIR/share/mk/bsd.lib.mk \ --replace '-o ''${DEBUGOWN} -g ''${DEBUGGRP}' "" \ --replace '-o ''${LIBOWN} -g ''${LIBGRP}' "" - - substituteInPlace $NETBSDSRCDIR/share/mk/Makefile \ - --replace /usr/share/mk /share/mk + '' + lib.optionalString stdenv.isDarwin '' substituteInPlace $NETBSDSRCDIR/share/mk/bsd.sys.mk \ --replace '-Wl,--fatal-warnings' "" substituteInPlace $NETBSDSRCDIR/share/mk/bsd.lib.mk \ - --replace ' ''${_ARFL} ''${.TARGET} `NM=''${NM} ''${LORDER} ''${.ALLSRC:M*o} | ''${TSORT}`' ' ''${_ARFL} ''${.TARGET} ''${.ALLSRC:M*o}' \ --replace '-Wl,-soname,''${_LIB}.so.''${SHLIB_SOVERSION}' "" \ --replace '-Wl,--whole-archive' "" \ --replace '-Wl,--no-whole-archive' "" @@ -340,8 +362,36 @@ in rec { version = "7.1.2"; patchPhase = '' sed -i '1i #include ' adventure/save.c + + # Disable some games that don't build. They should be possible to + # build but need to look at how to implement stuff in Linux. + substituteInPlace Makefile \ + ${lib.optionalString stdenv.isDarwin "--replace adventure ''"} \ + --replace atc "" \ + --replace boggle "" \ + --replace dm "" \ + --replace fortune "" \ + --replace hunt "" \ + --replace larn "" \ + --replace phantasia "" \ + --replace rogue "" \ + --replace sail "" \ + --replace trek "" \ + --replace dab "" ''; - buildInputs = [ compat libcurses ]; + NIX_CFLAGS_COMPILE = [ + "-D__noinline=" + "-D__scanflike(a,b)=" + "-D__va_list=va_list" + "-DOXTABS=XTABS" + "-DRANDOM_MAX=RAND_MAX" + "-DINFTIM=-1" + ]; + buildInputs = [ compat libcurses libterminfo libressl ]; + extraPaths = [ + (fetchNetBSD "share/dict" "7.1.2" "0nickhsjwgnr2h9nvwflvgfz93kqms5hzdnpyq02crpj35w98bh4") + who.src + ]; }; who = netBSDDerivation { @@ -358,8 +408,8 @@ in rec { }; fingerd = netBSDDerivation { - path = "usr.bin/fingerd"; - sha256 = "04wjsang8f8kxsifiayklbxaaxmm3vx9rfr91hfbxj4hk8gkqz00"; + path = "libexec/fingerd"; + sha256 = "1hhdq70hrxxkjnjfmjm3w8w9g9xq2ngxaxk0chy4vm7chg9nfpmp"; version = "7.1.2"; }; @@ -367,9 +417,17 @@ in rec { path = "lib/libedit"; buildInputs = [ libterminfo libcurses ]; propagatedBuildInputs = [ compat ]; + postBuild = "mkdir -p $out/usr/include/readline"; patchPhase = '' sed -i '1i #undef bool_t' el.h + substituteInPlace config.h \ + --replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" "" ''; + NIX_CFLAGS_COMPILE = [ + "-D__noinline=" + "-D__scanflike(a,b)=" + "-D__va_list=va_list" + ]; version = "7.1.2"; sha256 = "0qvr52j4qih10m7fa8nddn1psyjy9l0pa4ix02acyssjvgbz2kca"; }; @@ -389,8 +447,20 @@ in rec { version = "7.1.2"; sha256 = "04djah9dadzw74nswn0xydkxn900kav8xdvxlxdl50nbrynxg9yf"; buildInputs = [ libterminfo ]; + NIX_CFLAGS_COMPILE = [ + "-D__scanflike(a,b)=" + "-D__va_list=va_list" + "-D__warn_references(a,b)=" + ]; propagatedBuildInputs = [ compat ]; MKDOC = "no"; # missing vfontedpr + patchPhase = '' + substituteInPlace printw.c \ + --replace "funopen(win, NULL, __winwrite, NULL, NULL)" NULL \ + --replace "__strong_alias(vwprintw, vw_printw)" 'extern int vwprintw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_printw")));' + substituteInPlace scanw.c \ + --replace "__strong_alias(vwscanw, vw_scanw)" 'extern int vwscanw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_scanw")));' + ''; }; nbperf = netBSDDerivation { From 3ee2db1ab1cdede280dbcab66fd85329e2345bb6 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 27 Apr 2018 22:32:20 +0000 Subject: [PATCH 07/14] netbsd: fix games on linux --- pkgs/os-specific/bsd/netbsd/default.nix | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 67ad3687c2c..75bd85be49d 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -108,10 +108,10 @@ let # will be removed in the postInstall. preInstall = '' mkdir -p $out$BINDIR $out$LIBDIR $out$INFODIR \ - $out$DOCDIR $out$LOCALEDIR $out/usr/games + $out$DOCDIR $out$LOCALEDIR for i in 1 2 3 4 5 6 7 8 9; do mkdir -p $out$MANDIR/man$i $out$MANDIR/html$i \ - $out$DOCDIR/reference/ref$i + $out$DOCDIR/reference/ref$i done mkdir -p $out/usr/include ''; @@ -363,8 +363,10 @@ in rec { patchPhase = '' sed -i '1i #include ' adventure/save.c - # Disable some games that don't build. They should be possible to - # build but need to look at how to implement stuff in Linux. + # Disable some games that don't build. They should be possible + # to build but need to look at how to implement stuff in + # Linux. macOS is missing gettime. TODO try to get these + # working. substituteInPlace Makefile \ ${lib.optionalString stdenv.isDarwin "--replace adventure ''"} \ --replace atc "" \ @@ -378,6 +380,9 @@ in rec { --replace sail "" \ --replace trek "" \ --replace dab "" + substituteInPlace Makefile.inc \ + --replace 2555 555 \ + --replace 2550 550 ''; NIX_CFLAGS_COMPILE = [ "-D__noinline=" @@ -387,6 +392,17 @@ in rec { "-DRANDOM_MAX=RAND_MAX" "-DINFTIM=-1" ]; + postBuild = '' + mkdir -p $out/usr/games $out/usr/share/games/ching \ + $out/usr/share/games/quiz.db \ + $out/usr/libexec/ching $out/var/games/hackdir + touch $out/var/games/hackdir/perm + ''; + preFixup = '' + mkdir -p $out/bin + mv $out/games/* $out/bin + rmdir $out/games + ''; buildInputs = [ compat libcurses libterminfo libressl ]; extraPaths = [ (fetchNetBSD "share/dict" "7.1.2" "0nickhsjwgnr2h9nvwflvgfz93kqms5hzdnpyq02crpj35w98bh4") From e2fb669bc5154e13dfe78cd19b7727ed7a0248e9 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 27 Apr 2018 22:52:54 +0000 Subject: [PATCH 08/14] netbsd: fix finger --- pkgs/os-specific/bsd/netbsd/default.nix | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 75bd85be49d..c44e25b00fc 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -340,6 +340,19 @@ let sha256 = "1dhsyfvcm67kf5zdbg5dmx5y8fimnbll6qxwp3gjfmbxqigmc52m"; }; + who = netBSDDerivation { + path = "usr.bin/who"; + version = "7.1.2"; + sha256 = "17ffwww957m3qw0b6fkgjpp12pd5ydg2hs9dxkkw0qpv11j00d88"; + patchPhase = '' + substituteInPlace $NETBSDSRCDIR/usr.bin/who/utmpentry.c \ + --replace "strncpy(e->name, up->ut_name, sizeof(up->ut_name))" "strncpy(e->name, up->ut_user, sizeof(up->ut_user))" \ + --replace "utmptime = st.st_mtimespec" "utmptime = st.st_mtim" \ + --replace "timespeccmp(&st.st_mtimespec, &utmptime, >)" "st.st_mtim.tv_sec == utmptime.tv_sec ? st.st_mtim.tv_nsec > utmptime.tv_nsec : st.st_mtim.tv_sec > utmptime.tv_sec" \ + --replace "timespecclear(&utmptime)" "utmptime.tv_sec = utmptime.tv_nsec = 0" + ''; + }; + in rec { inherit compat install netBSDDerivation fts; @@ -410,17 +423,20 @@ in rec { ]; }; - who = netBSDDerivation { - path = "usr.bin/who"; - version = "7.1.2"; - sha256 = "17ffwww957m3qw0b6fkgjpp12pd5ydg2hs9dxkkw0qpv11j00d88"; - }; - finger = netBSDDerivation { path = "usr.bin/finger"; sha256 = "0jl672z50f2yf7ikp682b3xrarm6bnrrx9vi94xnp2fav8m8zfyi"; version = "7.1.2"; extraPaths = [ who.src ]; + NIX_CFLAGS_COMPILE = [ + "-DSUPPORT_UTMP" + "-USUPPORT_UTMPX" + ]; + patchPhase = '' + + ${who.patchPhase} + + ''; }; fingerd = netBSDDerivation { From c65000af91d91708a1afbb4cb24b1daac068aaa0 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 28 Apr 2018 00:33:51 +0000 Subject: [PATCH 09/14] openbsd: fixup mg --- pkgs/os-specific/bsd/default.nix | 2 +- pkgs/os-specific/bsd/openbsd/default.nix | 28 +- pkgs/os-specific/bsd/openbsd/nc.patch | 421 ----------------------- 3 files changed, 18 insertions(+), 433 deletions(-) delete mode 100644 pkgs/os-specific/bsd/openbsd/nc.patch diff --git a/pkgs/os-specific/bsd/default.nix b/pkgs/os-specific/bsd/default.nix index a8301ea2a8f..5f094a8dad3 100644 --- a/pkgs/os-specific/bsd/default.nix +++ b/pkgs/os-specific/bsd/default.nix @@ -3,6 +3,6 @@ rec { netbsd = recurseIntoAttrs (callPackages ./netbsd {}); openbsd = recurseIntoAttrs (callPackages ./openbsd { - inherit (netbsd) compat netBSDDerivation libcurses; + inherit (netbsd) compat netBSDDerivation libcurses libterminfo; }); } diff --git a/pkgs/os-specific/bsd/openbsd/default.nix b/pkgs/os-specific/bsd/openbsd/default.nix index 9ccc0adaa2d..6d909e1c556 100644 --- a/pkgs/os-specific/bsd/openbsd/default.nix +++ b/pkgs/os-specific/bsd/openbsd/default.nix @@ -1,4 +1,4 @@ -{ fetchcvs, netBSDDerivation, compat, libcurses, libressl }: +{ fetchcvs, netBSDDerivation, compat, libcurses, libterminfo }: let fetchOpenBSD = path: version: sha256: fetchcvs { @@ -21,22 +21,28 @@ in { path = "usr.bin/mg"; version = "6.3"; sha256 = "0n3hwa81c2mcjwbmidrbvi1l25jh8hy939kqrigbv78jixpynffc"; - buildInputs = [ compat libcurses ]; + buildInputs = [ compat libcurses libterminfo ]; patchPhase = '' NIX_CFLAGS_COMPILE+=" -I$BSDSRCDIR/sys" + substituteInPlace fileio.c \ + --replace "bp->b_fi.fi_mtime.tv_sec != sb.st_mtimespec.tv_sec" "bp->b_fi.fi_mtime.tv_sec != sb.st_mtim.tv_sec" \ + --replace "bp->b_fi.fi_mtime.tv_nsec != sb.st_mtimespec.tv_nsec" "bp->b_fi.fi_mtime.tv_nsec != sb.st_mtim.tv_nsec" \ + --replace "bp->b_fi.fi_mtime = sb.st_mtimespec" "bp->b_fi.fi_mtime = sb.st_mtim" + substituteInPlace Makefile \ + --replace "-o root -g wheel" "" \ + --replace '-o ''${DOCOWN} -g ''${DOCGRP}' "" + ''; + NIX_CFLAGS_COMPILE = [ "-DTCSASOFT=0x10" "-Dpledge(a,b)=0" ]; + preBuild = '' + cc -c $BSDSRCDIR/lib/libc/stdlib/strtonum.c -o strtonum.o + NIX_LDFLAGS+=" strtonum.o" ''; extraPaths = [ (fetchOpenBSD "sys/sys/tree.h" "6.3" "0rimh41wn9wz5m510zk9i27z3s450qqgq2k5xn8kp3885hygbcj9") (fetchOpenBSD "sys/sys/_null.h" "6.3" "0l2rgg9ai4ivfl07zmbqli19vnm3lj7qkxpikqplmzrfp36qpzgr") - ]; - }; - - nc = openBSDDerivation { - path = "usr.bin/nc"; - version = "6.3"; - sha256 = "0fmnh6ccxab0qvhmgspyd3wra1ps2516i0j6hwkvna2lcny20xvr"; - patches = [ ./nc.patch ]; - buildInputs = [ compat libressl ]; + (fetchOpenBSD "sys/sys/_null.h" "6.3" "0l2rgg9ai4ivfl07zmbqli19vnm3lj7qkxpikqplmzrfp36qpzgr") + (fetchOpenBSD "lib/libc/stdlib/strtonum.c" "6.3" "0xn3qxvb3g76hz698sjkf85p07zrcdv2g31inp8caqw2mpk6jadv") + ]; }; } diff --git a/pkgs/os-specific/bsd/openbsd/nc.patch b/pkgs/os-specific/bsd/openbsd/nc.patch deleted file mode 100644 index de6fb2d04c4..00000000000 --- a/pkgs/os-specific/bsd/openbsd/nc.patch +++ /dev/null @@ -1,421 +0,0 @@ ---- a/nc.1 -+++ b/nc.1 -@@ -204,9 +204,6 @@ Proxy authentication is only supported f - Specifies the source port - .Nm - should use, subject to privilege restrictions and availability. --It is an error to use this option in conjunction with the --.Fl l --option. - .It Fl R Ar CAfile - Specifies the filename from which the root CA bundle for certificate - verification is loaded, in PEM format. -@@ -258,6 +255,7 @@ For IPv4 TOS value - may be one of - .Ar critical , - .Ar inetcontrol , -+.Ar lowcost , - .Ar lowdelay , - .Ar netcontrol , - .Ar throughput , ---- a/netcat.c -+++ b/netcat.c -@@ -32,6 +32,8 @@ - * *Hobbit* . - */ - -+#define _GNU_SOURCE -+ - #include - #include - #include -@@ -41,6 +43,49 @@ - #include - #include - #include -+#ifdef __linux__ -+# include -+#endif -+ -+#ifndef IPTOS_LOWDELAY -+# define IPTOS_LOWDELAY 0x10 -+# define IPTOS_THROUGHPUT 0x08 -+# define IPTOS_RELIABILITY 0x04 -+# define IPTOS_LOWCOST 0x02 -+# define IPTOS_MINCOST IPTOS_LOWCOST -+#endif /* IPTOS_LOWDELAY */ -+ -+# ifndef IPTOS_DSCP_AF11 -+# define IPTOS_DSCP_AF11 0x28 -+# define IPTOS_DSCP_AF12 0x30 -+# define IPTOS_DSCP_AF13 0x38 -+# define IPTOS_DSCP_AF21 0x48 -+# define IPTOS_DSCP_AF22 0x50 -+# define IPTOS_DSCP_AF23 0x58 -+# define IPTOS_DSCP_AF31 0x68 -+# define IPTOS_DSCP_AF32 0x70 -+# define IPTOS_DSCP_AF33 0x78 -+# define IPTOS_DSCP_AF41 0x88 -+# define IPTOS_DSCP_AF42 0x90 -+# define IPTOS_DSCP_AF43 0x98 -+# define IPTOS_DSCP_EF 0xb8 -+#endif /* IPTOS_DSCP_AF11 */ -+ -+#ifndef IPTOS_DSCP_CS0 -+# define IPTOS_DSCP_CS0 0x00 -+# define IPTOS_DSCP_CS1 0x20 -+# define IPTOS_DSCP_CS2 0x40 -+# define IPTOS_DSCP_CS3 0x60 -+# define IPTOS_DSCP_CS4 0x80 -+# define IPTOS_DSCP_CS5 0xa0 -+# define IPTOS_DSCP_CS6 0xc0 -+# define IPTOS_DSCP_CS7 0xe0 -+#endif /* IPTOS_DSCP_CS0 */ -+ -+#ifndef IPTOS_DSCP_EF -+# define IPTOS_DSCP_EF 0xb8 -+#endif /* IPTOS_DSCP_EF */ -+ - - #include - #include -@@ -268,10 +315,14 @@ main(int argc, char *argv[]) - uflag = 1; - break; - case 'V': -+# if defined(RT_TABLEID_MAX) - rtableid = (int)strtonum(optarg, 0, - RT_TABLEID_MAX, &errstr); - if (errstr) - errx(1, "rtable %s: %s", errstr, optarg); -+# else -+ errx(1, "no alternate routing table support available"); -+# endif - break; - case 'v': - vflag = 1; -@@ -320,7 +371,11 @@ main(int argc, char *argv[]) - oflag = optarg; - break; - case 'S': -+# if defined(TCP_MD5SIG) - Sflag = 1; -+# else -+ errx(1, "no TCP MD5 signature support available"); -+# endif - break; - case 'T': - errstr = NULL; -@@ -345,35 +400,23 @@ main(int argc, char *argv[]) - argc -= optind; - argv += optind; - -+# if defined(RT_TABLEID_MAX) - if (rtableid >= 0) - if (setrtable(rtableid) == -1) - err(1, "setrtable"); -- -- if (family == AF_UNIX) { -- if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1) -- err(1, "pledge"); -- } else if (Fflag && Pflag) { -- if (pledge("stdio inet dns sendfd tty", NULL) == -1) -- err(1, "pledge"); -- } else if (Fflag) { -- if (pledge("stdio inet dns sendfd", NULL) == -1) -- err(1, "pledge"); -- } else if (Pflag && usetls) { -- if (pledge("stdio rpath inet dns tty", NULL) == -1) -- err(1, "pledge"); -- } else if (Pflag) { -- if (pledge("stdio inet dns tty", NULL) == -1) -- err(1, "pledge"); -- } else if (usetls) { -- if (pledge("stdio rpath inet dns", NULL) == -1) -- err(1, "pledge"); -- } else if (pledge("stdio inet dns", NULL) == -1) -- err(1, "pledge"); -+# endif - - /* Cruft to make sure options are clean, and used properly. */ - if (argv[0] && !argv[1] && family == AF_UNIX) { - host = argv[0]; - uport = NULL; -+ } else if (!argv[0] && lflag) { -+ if (sflag) -+ errx(1, "cannot use -s and -l"); -+ if (pflag) -+ errx(1, "cannot use -p and -l"); -+ if (zflag) -+ errx(1, "cannot use -z and -l"); - } else if (argv[0] && !argv[1]) { - if (!lflag) - usage(1); -@@ -385,12 +428,6 @@ main(int argc, char *argv[]) - } else - usage(1); - -- if (lflag && sflag) -- errx(1, "cannot use -s and -l"); -- if (lflag && pflag) -- errx(1, "cannot use -p and -l"); -- if (lflag && zflag) -- errx(1, "cannot use -z and -l"); - if (!lflag && kflag) - errx(1, "must use -l with -k"); - if (uflag && usetls) -@@ -425,8 +462,8 @@ main(int argc, char *argv[]) - } else { - strlcpy(unix_dg_tmp_socket_buf, "/tmp/nc.XXXXXXXXXX", - UNIX_DG_TMP_SOCKET_SIZE); -- if (mktemp(unix_dg_tmp_socket_buf) == NULL) -- err(1, "mktemp"); -+ if (mkstemp(unix_dg_tmp_socket_buf) == -1) -+ err(1, "mkstemp"); - unix_dg_tmp_socket = unix_dg_tmp_socket_buf; - } - } -@@ -901,8 +938,10 @@ remote_connect(const char *host, const c - if (sflag || pflag) { - struct addrinfo ahints, *ares; - -+# if defined (SO_BINDANY) - /* try SO_BINDANY, but don't insist */ - setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on)); -+# endif - memset(&ahints, 0, sizeof(struct addrinfo)); - ahints.ai_family = res->ai_family; - ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; -@@ -994,9 +1033,15 @@ local_listen(char *host, char *port, str - res->ai_protocol)) < 0) - continue; - -+ ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x)); -+ if (ret == -1) -+ err(1, NULL); -+ -+# if defined(SO_REUSEPORT) - ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); - if (ret == -1) - err(1, NULL); -+# endif - - set_common_sockopts(s, res->ai_family); - -@@ -1452,11 +1497,13 @@ set_common_sockopts(int s, int af) - { - int x = 1; - -+# if defined(TCP_MD5SIG) - if (Sflag) { - if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, - &x, sizeof(x)) == -1) - err(1, NULL); - } -+# endif - if (Dflag) { - if (setsockopt(s, SOL_SOCKET, SO_DEBUG, - &x, sizeof(x)) == -1) -@@ -1467,9 +1514,14 @@ set_common_sockopts(int s, int af) - IP_TOS, &Tflag, sizeof(Tflag)) == -1) - err(1, "set IP ToS"); - -+#if defined(IPV6_TCLASS) - else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, - IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1) - err(1, "set IPv6 traffic class"); -+#else -+ else if (af == AF_INET6) -+ errx(1, "can't set IPv6 traffic class (unavailable)"); -+#endif - } - if (Iflag) { - if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, -@@ -1487,19 +1539,34 @@ set_common_sockopts(int s, int af) - IP_TTL, &ttl, sizeof(ttl))) - err(1, "set IP TTL"); - -+#if defined(IPV6_UNICAST_HOPS) - else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, - IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) - err(1, "set IPv6 unicast hops"); -+#else -+ else if (af == AF_INET6) -+ errx(1, "can't set IPv6 unicast hops (unavailable)"); -+#endif - } - - if (minttl != -1) { -+#if defined(IP_MINTTL) - if (af == AF_INET && setsockopt(s, IPPROTO_IP, - IP_MINTTL, &minttl, sizeof(minttl))) - err(1, "set IP min TTL"); -+#else -+ if (af == AF_INET) -+ errx(1, "can't set IP min TTL (unavailable)"); -+#endif - -+#if defined(IPV6_MINHOPCOUNT) - else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, - IPV6_MINHOPCOUNT, &minttl, sizeof(minttl))) - err(1, "set IPv6 min hop count"); -+#else -+ else if (af == AF_INET6) -+ errx(1, "can't set IPv6 min hop count (unavailable)"); -+#endif - } - } - -@@ -1534,6 +1601,7 @@ process_tos_opt(char *s, int *val) - { "cs7", IPTOS_DSCP_CS7 }, - { "ef", IPTOS_DSCP_EF }, - { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, -+ { "lowcost", IPTOS_LOWCOST }, - { "lowdelay", IPTOS_LOWDELAY }, - { "netcontrol", IPTOS_PREC_NETCONTROL }, - { "reliability", IPTOS_RELIABILITY }, -@@ -1741,7 +1812,7 @@ help(void) - \t-Z Peer certificate file\n\ - \t-z Zero-I/O mode [used for scanning]\n\ - Port numbers can be individual or ranges: lo-hi [inclusive]\n"); -- exit(1); -+ exit(0); - } - - void ---- a/socks.c -+++ b/socks.c -@@ -219,11 +219,11 @@ socks_connect(const char *host, const ch - buf[2] = SOCKS_NOAUTH; - cnt = atomicio(vwrite, proxyfd, buf, 3); - if (cnt != 3) -- err(1, "write failed (%zu/3)", cnt); -+ err(1, "write failed (%zu/3)", (size_t)cnt); - - cnt = atomicio(read, proxyfd, buf, 2); - if (cnt != 2) -- err(1, "read failed (%zu/3)", cnt); -+ err(1, "read failed (%zu/3)", (size_t)cnt); - - if (buf[1] == SOCKS_NOMETHOD) - errx(1, "authentication method negotiation failed"); -@@ -272,11 +272,11 @@ socks_connect(const char *host, const ch - - cnt = atomicio(vwrite, proxyfd, buf, wlen); - if (cnt != wlen) -- err(1, "write failed (%zu/%zu)", cnt, wlen); -+ err(1, "write failed (%zu/%zu)", (size_t)cnt, (size_t)wlen); - - cnt = atomicio(read, proxyfd, buf, 4); - if (cnt != 4) -- err(1, "read failed (%zu/4)", cnt); -+ err(1, "read failed (%zu/4)", (size_t)cnt); - if (buf[1] != 0) { - errx(1, "connection failed, SOCKSv5 error: %s", - socks5_strerror(buf[1])); -@@ -285,12 +285,12 @@ socks_connect(const char *host, const ch - case SOCKS_IPV4: - cnt = atomicio(read, proxyfd, buf + 4, 6); - if (cnt != 6) -- err(1, "read failed (%zu/6)", cnt); -+ err(1, "read failed (%zu/6)", (size_t)cnt); - break; - case SOCKS_IPV6: - cnt = atomicio(read, proxyfd, buf + 4, 18); - if (cnt != 18) -- err(1, "read failed (%zu/18)", cnt); -+ err(1, "read failed (%zu/18)", (size_t)cnt); - break; - default: - errx(1, "connection failed, unsupported address type"); -@@ -310,11 +310,11 @@ socks_connect(const char *host, const ch - - cnt = atomicio(vwrite, proxyfd, buf, wlen); - if (cnt != wlen) -- err(1, "write failed (%zu/%zu)", cnt, wlen); -+ err(1, "write failed (%zu/%zu)", (size_t)cnt, (size_t)wlen); - - cnt = atomicio(read, proxyfd, buf, 8); - if (cnt != 8) -- err(1, "read failed (%zu/8)", cnt); -+ err(1, "read failed (%zu/8)", (size_t)cnt); - if (buf[1] != 90) { - errx(1, "connection failed, SOCKSv4 error: %s", - socks4_strerror(buf[1])); -@@ -328,39 +328,39 @@ socks_connect(const char *host, const ch - - /* Try to be sane about numeric IPv6 addresses */ - if (strchr(host, ':') != NULL) { -- r = snprintf(buf, sizeof(buf), -+ r = snprintf((char*)buf, sizeof(buf), - "CONNECT [%s]:%d HTTP/1.0\r\n", - host, ntohs(serverport)); - } else { -- r = snprintf(buf, sizeof(buf), -+ r = snprintf((char*)buf, sizeof(buf), - "CONNECT %s:%d HTTP/1.0\r\n", - host, ntohs(serverport)); - } - if (r == -1 || (size_t)r >= sizeof(buf)) - errx(1, "hostname too long"); -- r = strlen(buf); -+ r = strlen((char*)buf); - - cnt = atomicio(vwrite, proxyfd, buf, r); - if (cnt != r) -- err(1, "write failed (%zu/%d)", cnt, r); -+ err(1, "write failed (%zu/%d)", (size_t)cnt, (int)r); - - if (authretry > 1) { - char resp[1024]; - - proxypass = getproxypass(proxyuser, proxyhost); -- r = snprintf(buf, sizeof(buf), "%s:%s", -+ r = snprintf((char*)buf, sizeof(buf), "%s:%s", - proxyuser, proxypass); - if (r == -1 || (size_t)r >= sizeof(buf) || -- b64_ntop(buf, strlen(buf), resp, -+ b64_ntop(buf, strlen((char*)buf), resp, - sizeof(resp)) == -1) - errx(1, "Proxy username/password too long"); -- r = snprintf(buf, sizeof(buf), "Proxy-Authorization: " -+ r = snprintf((char*)buf, sizeof(buf), "Proxy-Authorization: " - "Basic %s\r\n", resp); - if (r == -1 || (size_t)r >= sizeof(buf)) - errx(1, "Proxy auth response too long"); -- r = strlen(buf); -+ r = strlen((char*)buf); - if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) -- err(1, "write failed (%zu/%d)", cnt, r); -+ err(1, "write failed (%zu/%d)", (size_t)cnt, r); - } - - /* Terminate headers */ -@@ -368,22 +368,22 @@ socks_connect(const char *host, const ch - err(1, "write failed (%zu/2)", cnt); - - /* Read status reply */ -- proxy_read_line(proxyfd, buf, sizeof(buf)); -+ proxy_read_line(proxyfd, (char*)buf, sizeof(buf)); - if (proxyuser != NULL && -- strncmp(buf, "HTTP/1.0 407 ", 12) == 0) { -+ strncmp((char*)buf, "HTTP/1.0 407 ", 12) == 0) { - if (authretry > 1) { - fprintf(stderr, "Proxy authentication " - "failed\n"); - } - close(proxyfd); - goto again; -- } else if (strncmp(buf, "HTTP/1.0 200 ", 12) != 0 && -- strncmp(buf, "HTTP/1.1 200 ", 12) != 0) -+ } else if (strncmp((char*)buf, "HTTP/1.0 200 ", 12) != 0 && -+ strncmp((char*)buf, "HTTP/1.1 200 ", 12) != 0) - errx(1, "Proxy error: \"%s\"", buf); - - /* Headers continue until we hit an empty line */ - for (r = 0; r < HTTP_MAXHDRS; r++) { -- proxy_read_line(proxyfd, buf, sizeof(buf)); -+ proxy_read_line(proxyfd, (char*)buf, sizeof(buf)); - if (*buf == '\0') - break; - } \ No newline at end of file From 6bc19398bed6a4062979c86454e41581f0bddbc7 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 28 Apr 2018 01:03:34 +0000 Subject: [PATCH 10/14] openbsd: remove --- pkgs/os-specific/bsd/default.nix | 3 -- pkgs/os-specific/bsd/openbsd/default.nix | 48 ------------------------ pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 pkgs/os-specific/bsd/openbsd/default.nix diff --git a/pkgs/os-specific/bsd/default.nix b/pkgs/os-specific/bsd/default.nix index 5f094a8dad3..a75c132b55a 100644 --- a/pkgs/os-specific/bsd/default.nix +++ b/pkgs/os-specific/bsd/default.nix @@ -2,7 +2,4 @@ rec { netbsd = recurseIntoAttrs (callPackages ./netbsd {}); - openbsd = recurseIntoAttrs (callPackages ./openbsd { - inherit (netbsd) compat netBSDDerivation libcurses libterminfo; - }); } diff --git a/pkgs/os-specific/bsd/openbsd/default.nix b/pkgs/os-specific/bsd/openbsd/default.nix deleted file mode 100644 index 6d909e1c556..00000000000 --- a/pkgs/os-specific/bsd/openbsd/default.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ fetchcvs, netBSDDerivation, compat, libcurses, libterminfo }: - -let - fetchOpenBSD = path: version: sha256: fetchcvs { - cvsRoot = "anoncvs@anoncvs.ca.openbsd.org:/cvs"; - module = "src/${path}"; - inherit sha256; - tag = "OPENBSD_${builtins.replaceStrings ["."] ["_"] version}"; - }; - - # OpenBSD is a fork of NetBSD - # We can build it with minimal changes - openBSDDerivation = attrs: netBSDDerivation (attrs // { - name = "${attrs.pname or (baseNameOf attrs.path)}-openbsd-${attrs.version}"; - src = fetchOpenBSD attrs.path attrs.version attrs.sha256; - }); - -in { - - mg = openBSDDerivation { - path = "usr.bin/mg"; - version = "6.3"; - sha256 = "0n3hwa81c2mcjwbmidrbvi1l25jh8hy939kqrigbv78jixpynffc"; - buildInputs = [ compat libcurses libterminfo ]; - patchPhase = '' - NIX_CFLAGS_COMPILE+=" -I$BSDSRCDIR/sys" - substituteInPlace fileio.c \ - --replace "bp->b_fi.fi_mtime.tv_sec != sb.st_mtimespec.tv_sec" "bp->b_fi.fi_mtime.tv_sec != sb.st_mtim.tv_sec" \ - --replace "bp->b_fi.fi_mtime.tv_nsec != sb.st_mtimespec.tv_nsec" "bp->b_fi.fi_mtime.tv_nsec != sb.st_mtim.tv_nsec" \ - --replace "bp->b_fi.fi_mtime = sb.st_mtimespec" "bp->b_fi.fi_mtime = sb.st_mtim" - substituteInPlace Makefile \ - --replace "-o root -g wheel" "" \ - --replace '-o ''${DOCOWN} -g ''${DOCGRP}' "" - ''; - NIX_CFLAGS_COMPILE = [ "-DTCSASOFT=0x10" "-Dpledge(a,b)=0" ]; - preBuild = '' - cc -c $BSDSRCDIR/lib/libc/stdlib/strtonum.c -o strtonum.o - NIX_LDFLAGS+=" strtonum.o" - ''; - extraPaths = [ - (fetchOpenBSD "sys/sys/tree.h" "6.3" "0rimh41wn9wz5m510zk9i27z3s450qqgq2k5xn8kp3885hygbcj9") - (fetchOpenBSD "sys/sys/_null.h" "6.3" "0l2rgg9ai4ivfl07zmbqli19vnm3lj7qkxpikqplmzrfp36qpzgr") - (fetchOpenBSD "sys/sys/_null.h" "6.3" "0l2rgg9ai4ivfl07zmbqli19vnm3lj7qkxpikqplmzrfp36qpzgr") - (fetchOpenBSD "lib/libc/stdlib/strtonum.c" "6.3" "0xn3qxvb3g76hz698sjkf85p07zrcdv2g31inp8caqw2mpk6jadv") - ]; - }; - -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 31a1acff06e..beffac76715 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21379,5 +21379,5 @@ with pkgs; mount wall hostname more sysctl; inherit (recurseIntoAttrs (callPackages ../os-specific/bsd { })) - netbsd openbsd; + netbsd; } From 004111c27e11684d6945f82124110c5f17c1bf01 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 28 Apr 2018 01:03:47 +0000 Subject: [PATCH 11/14] netbsd: small fixups --- pkgs/os-specific/bsd/netbsd/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index c44e25b00fc..f9c8653447f 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -11,7 +11,7 @@ let netBSDDerivation = attrs: stdenv.mkDerivation ((rec { name = "${attrs.pname or (baseNameOf attrs.path)}-netbsd-${attrs.version}"; - src = fetchNetBSD attrs.path attrs.version attrs.sha256; + src = attrs.src or fetchNetBSD attrs.path attrs.version attrs.sha256; extraPaths = [ ]; @@ -187,6 +187,7 @@ let 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 From d11f290f670d04071f893deea891a373e1548821 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 28 Apr 2018 01:31:06 +0000 Subject: [PATCH 12/14] netbsd: cleanup and musl suppot --- pkgs/os-specific/bsd/netbsd/default.nix | 29 ++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index f9c8653447f..0cd2b4ffc6e 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -405,6 +405,7 @@ in rec { "-DOXTABS=XTABS" "-DRANDOM_MAX=RAND_MAX" "-DINFTIM=-1" + (if hostPlatform.isMusl then "-include sys/ttydefaults.h -include sys/file.h" else "") ]; postBuild = '' mkdir -p $out/usr/games $out/usr/share/games/ching \ @@ -424,21 +425,19 @@ in rec { ]; }; - finger = netBSDDerivation { - path = "usr.bin/finger"; - sha256 = "0jl672z50f2yf7ikp682b3xrarm6bnrrx9vi94xnp2fav8m8zfyi"; - version = "7.1.2"; - extraPaths = [ who.src ]; - NIX_CFLAGS_COMPILE = [ - "-DSUPPORT_UTMP" - "-USUPPORT_UTMPX" - ]; - patchPhase = '' - - ${who.patchPhase} - - ''; - }; + # finger = netBSDDerivation { + # path = "usr.bin/finger"; + # sha256 = "0jl672z50f2yf7ikp682b3xrarm6bnrrx9vi94xnp2fav8m8zfyi"; + # version = "7.1.2"; + # extraPaths = [ who.src ]; + # NIX_CFLAGS_COMPILE = [ + # "-DSUPPORT_UTMP" + # "-USUPPORT_UTMPX" + # ]; + # patchPhase = '' + # ${who.patchPhase} + # ''; + # }; fingerd = netBSDDerivation { path = "libexec/fingerd"; From 5f419f3df7f71b9dd88e513fcdd1303a5d5b99dd Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 27 Apr 2018 20:50:15 -0500 Subject: [PATCH 13/14] netbsd: improve darwin support --- pkgs/os-specific/bsd/netbsd/default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 0cd2b4ffc6e..343b61bab38 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -68,10 +68,10 @@ let HOST_SH = "${bash}/bin/sh"; - # not using bsd binutils SHLIB_WARNTEXTREL = "no"; SHLIB_MKMAP = "no"; PRESERVE = "-p"; + OBJCOPY = if stdenv.isDarwin then "true" else "objcopy"; MACHINE_ARCH = hostPlatform.parsed.cpu.name; MACHINE_CPU = hostPlatform.parsed.cpu.name; @@ -393,7 +393,7 @@ in rec { --replace rogue "" \ --replace sail "" \ --replace trek "" \ - --replace dab "" + --replace dab "" substituteInPlace Makefile.inc \ --replace 2555 555 \ --replace 2550 550 @@ -469,6 +469,7 @@ in rec { version = "7.1.2"; sha256 = "06plg0bjqgbb0aghpb9qlk8wkp1l2izdlr64vbr5laqyw8jg84zq"; buildInputs = [ compat tic nbperf ]; + MKPIC = if stdenv.isDarwin then "no" else "yes"; extraPaths = [ (fetchNetBSD "share/terminfo" "7.1.2" "1z5vzq8cw24j05r6df4vd6r57cvdbv7vbm4h962kplp14xrbg2h3") ]; @@ -483,10 +484,11 @@ in rec { "-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 ]; MKDOC = "no"; # missing vfontedpr - patchPhase = '' + MKPIC = if stdenv.isDarwin then "no" else "yes"; + patchPhase = lib.optionalString (!stdenv.isDarwin) '' substituteInPlace printw.c \ --replace "funopen(win, NULL, __winwrite, NULL, NULL)" NULL \ --replace "__strong_alias(vwprintw, vw_printw)" 'extern int vwprintw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_printw")));' From 0be5637139970d5ae6aef1999769b600765a95f6 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 29 Apr 2018 14:27:26 -0500 Subject: [PATCH 14/14] netbsd.games: disable more games on darwin --- pkgs/os-specific/bsd/netbsd/default.nix | 33 +++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 343b61bab38..ecd09eaff80 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -381,19 +381,26 @@ in rec { # to build but need to look at how to implement stuff in # Linux. macOS is missing gettime. TODO try to get these # working. - substituteInPlace Makefile \ - ${lib.optionalString stdenv.isDarwin "--replace adventure ''"} \ - --replace atc "" \ - --replace boggle "" \ - --replace dm "" \ - --replace fortune "" \ - --replace hunt "" \ - --replace larn "" \ - --replace phantasia "" \ - --replace rogue "" \ - --replace sail "" \ - --replace trek "" \ - --replace dab "" + disableGame() { + substituteInPlace Makefile --replace $1 "" + } + + disableGame atc + disableGame boggle + disableGame dm + disableGame fortune + disableGame hunt + disableGame larn + disableGame phantasia + disableGame rogue + disableGame sail + disableGame trek + disableGame dab + ${lib.optionalString stdenv.isDarwin "disableGame adventure"} + ${lib.optionalString stdenv.isDarwin "disableGame factor"} + ${lib.optionalString stdenv.isDarwin "disableGame gomoku"} + ${lib.optionalString stdenv.isDarwin "disableGame mille"} + substituteInPlace Makefile.inc \ --replace 2555 555 \ --replace 2550 550