1{ 2 stdenvNoCC, 3 callPackage, 4 fetchFromGitHub, 5 buildPackages, 6 lib, 7 enableMalloc ? false, 8 noPackedStructs ? false, 9 maxRequiredFields ? null, 10 field32bit ? false, 11 noErrmsg ? false, 12 bufferOnly ? false, 13 systemHeader ? null, 14 without64bit ? false, 15 encodeArraysUnpacked ? false, 16 convertDoubleFloat ? false, 17 validateUtf8 ? false, 18 littleEndian8bit ? false, 19 c99StaticAssert ? false, 20 noStaticAssert ? false, 21}: 22stdenvNoCC.mkDerivation ( 23 self: 24 let 25 generator-out = buildPackages.callPackage ./generator-out.nix { inherit (self) src version; }; 26 python-module = buildPackages.callPackage ./python-module.nix { 27 inherit (self) version; 28 inherit (self.passthru) generator-out; 29 }; 30 python3 = buildPackages.python3.override { 31 self = python3; 32 packageOverrides = _: _: { 33 nanopb-proto = self.passthru.python-module; 34 }; 35 }; 36 generator = buildPackages.callPackage ./generator.nix { 37 inherit python3; 38 inherit (self) version; 39 inherit (self.passthru) generator-out; 40 }; 41 runtime = callPackage ./runtime.nix { 42 inherit python3; 43 inherit (self) src version; 44 inherit 45 enableMalloc 46 noPackedStructs 47 maxRequiredFields 48 field32bit 49 noErrmsg 50 bufferOnly 51 systemHeader 52 without64bit 53 encodeArraysUnpacked 54 convertDoubleFloat 55 validateUtf8 56 littleEndian8bit 57 c99StaticAssert 58 noStaticAssert 59 ; 60 }; 61 in 62 { 63 pname = "nanopb"; 64 version = "0.4.9.1"; 65 66 src = fetchFromGitHub { 67 owner = "nanopb"; 68 repo = "nanopb"; 69 rev = self.version; 70 hash = "sha256-bMSZZaF8egAegi3enCM+DRyxOrPoWKAKybvWsrKZEDc="; 71 }; 72 73 dontPatch = true; 74 dontUnpack = true; 75 76 propagatedNativeBuildInputs = [ generator ]; 77 78 propagatedBuildInputs = [ runtime ]; 79 80 postInstall = '' 81 mkdir $out 82 ln -s ${generator}/bin $out/bin 83 ln -s ${runtime}/include $out/include 84 ln -s ${runtime}/lib $out/lib 85 mkdir -p $out/share/nanopb/generator/proto 86 ln -s ${self.src}/generator/proto/nanopb.proto $out/share/nanopb/generator/proto/nanopb.proto 87 ''; 88 89 passthru = { 90 inherit 91 runtime 92 generator-out 93 python-module 94 generator 95 ; 96 tests = { 97 simple-proto2 = callPackage ./test-simple-proto2 { }; 98 simple-proto3 = callPackage ./test-simple-proto3 { }; 99 message-with-annotations = callPackage ./test-message-with-annotations { }; 100 message-with-options = callPackage ./test-message-with-options { }; 101 }; 102 }; 103 104 meta = with lib; { 105 platforms = platforms.all; 106 107 description = "Protocol Buffers with small code size"; 108 homepage = "https://jpa.kapsi.fi/nanopb/"; 109 license = licenses.zlib; 110 maintainers = with maintainers; [ 111 kalbasit 112 liarokapisv 113 ]; 114 115 longDescription = '' 116 Nanopb is a small code-size Protocol Buffers implementation in ansi C. It 117 is especially suitable for use in microcontrollers, but fits any memory 118 restricted system. 119 120 - Homepage: jpa.kapsi.fi/nanopb 121 - Documentation: jpa.kapsi.fi/nanopb/docs 122 - Downloads: jpa.kapsi.fi/nanopb/download 123 - Forum: groups.google.com/forum/#!forum/nanopb 124 125 In order to use the nanopb options in your proto files, you'll need to 126 tell protoc where to find the nanopb.proto file. 127 You can do so with the --proto_path (-I) option to add the directory 128 ''${nanopb}/share/nanopb/generator/proto like so: 129 130 protoc --proto_path=. --proto_path=''${nanopb}/share/nanopb/generator/proto --plugin=protoc-gen-nanopb=''${nanopb}/bin/protoc-gen-nanopb --nanopb_out=out file.proto 131 ''; 132 }; 133 } 134)