nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchgit,
5 pkg-config,
6 patches ? [ ],
7 pkgsBuildHost,
8 enableStatic ? stdenv.hostPlatform.isStatic,
9}:
10
11stdenv.mkDerivation {
12 pname = "9base";
13 version = "unstable-2019-09-11";
14
15 src = fetchgit {
16 url = "https://git.suckless.org/9base";
17 rev = "63916da7bd6d73d9a405ce83fc4ca34845667cce";
18 hash = "sha256-CNK7Ycmcl5vkmtA5VKwKxGZz8AoIG1JH/LTKoYmWSBI=";
19 };
20
21 patches = [
22 # expects to be used with getcallerpc macro or stub patch
23 # AR env var is now the location of `ar` not including the arg (`ar rc`)
24 ./config-substitutions.patch
25 ./dont-strip.patch
26 # plan9port dropped their own getcallerpc implementations
27 # in favour of using gcc/clang's macros or a stub
28 # we can do this here too to extend platform support
29 # https://github.com/9fans/plan9port/commit/540caa5873bcc3bc2a0e1896119f5b53a0e8e630
30 # https://github.com/9fans/plan9port/commit/323e1a8fac276f008e6d5146a83cbc88edeabc87
31 ./getcallerpc-use-macro-or-stub.patch
32 # fix build with c23
33 # dd.c:315:30: error: expected identifier or '*' before 'true'
34 # n5.c:690:22: error: lvalue required as left operand of assignment
35 ./fix-build-with-c23.patch
36 ]
37 ++ patches;
38
39 # the 9yacc script needs to be executed to build other items
40 preBuild = lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
41 substituteInPlace ./yacc/9yacc \
42 --replace "../yacc/yacc" "${lib.getExe' pkgsBuildHost._9base "yacc"}"
43 '';
44
45 enableParallelBuilding = true;
46 strictDeps = true;
47 nativeBuildInputs = [ pkg-config ];
48 env.NIX_CFLAGS_COMPILE = toString [
49 # workaround build failure on -fno-common toolchains like upstream
50 # gcc-10. Otherwise build fails as:
51 # ld: diffio.o:(.bss+0x16): multiple definition of `bflag'; diffdir.o:(.bss+0x6): first defined here
52 "-fcommon"
53 # hide really common warning that floods the logs:
54 # warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
55 "-D_DEFAULT_SOURCE"
56 # error: call to undeclared function 'p9mbtowc'; ISO C99 and later do not support implicit function declarations
57 "-Wno-error=implicit-function-declaration"
58 ];
59 env.LDFLAGS = lib.optionalString enableStatic "-static";
60 makeFlags = [
61 "PREFIX=${placeholder "out"}"
62 ];
63 installFlags = [
64 "PREFIX_TROFF=${placeholder "troff"}"
65 ];
66
67 outputs = [
68 "out"
69 "man"
70 "troff"
71 ];
72
73 meta = {
74 homepage = "https://tools.suckless.org/9base/";
75 description = "Port of various original Plan 9 tools for Unix, based on plan9port";
76 longDescription = ''
77 9base is a port of various original Plan 9 tools for Unix, based on plan9port.
78 It also contains the Plan 9 libc, libbio, libregexp, libfmt and libutf.
79 The overall SLOC is about 66kSLOC, so this userland + all libs is much smaller than, e.g. bash.
80 9base can be used to run werc instead of the full blown plan9port.
81 '';
82 license = with lib.licenses; [
83 mit # and
84 lpl-102
85 ];
86 maintainers = with lib.maintainers; [ jk ];
87 platforms = lib.platforms.unix;
88 # needs additional work to support aarch64-darwin
89 # due to usage of _DARWIN_NO_64_BIT_INODE
90 broken = stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isDarwin;
91 };
92}