2019-12-08 08:00:34 +01:00
|
|
|
{ lib, buildGoModule, fetchFromGitHub, llvm, clang-unwrapped, lld, avrgcc
|
2020-05-01 03:59:00 +02:00
|
|
|
, avrdude, openocd, gcc-arm-embedded, makeWrapper, fetchurl }:
|
2019-12-08 08:00:34 +01:00
|
|
|
|
2020-05-01 03:59:00 +02:00
|
|
|
let main = ./main.go;
|
|
|
|
gomod = ./go.mod;
|
|
|
|
in
|
2019-12-08 08:00:34 +01:00
|
|
|
buildGoModule rec {
|
|
|
|
pname = "tinygo";
|
2020-12-12 16:56:08 +01:00
|
|
|
version = "0.16.0";
|
2019-12-08 08:00:34 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "tinygo-org";
|
|
|
|
repo = "tinygo";
|
|
|
|
rev = "v${version}";
|
2020-12-12 16:56:08 +01:00
|
|
|
sha256 = "063aszbsnr0myq56kms1slmrfs7m4nmg0zgh2p66lxdsifrfly7j";
|
|
|
|
fetchSubmodules = true;
|
2019-12-08 08:00:34 +01:00
|
|
|
};
|
2020-07-31 05:58:04 +02:00
|
|
|
|
2020-05-01 03:59:00 +02:00
|
|
|
overrideModAttrs = (_: {
|
|
|
|
patches = [];
|
|
|
|
preBuild = ''
|
|
|
|
rm -rf *
|
|
|
|
cp ${main} main.go
|
|
|
|
cp ${gomod} go.mod
|
2020-12-12 16:56:08 +01:00
|
|
|
chmod +w go.mod
|
2020-05-01 03:59:00 +02:00
|
|
|
'';
|
|
|
|
});
|
2019-12-08 08:00:34 +01:00
|
|
|
|
2020-05-01 03:59:00 +02:00
|
|
|
preBuild = "cp ${gomod} go.mod";
|
|
|
|
|
2020-12-12 16:56:08 +01:00
|
|
|
postBuild = "make gen-device";
|
|
|
|
|
|
|
|
vendorSha256 = "12k2gin0v7aqz5543m12yhifc0xsz26qyqra5l4c68xizvzcvkxb";
|
2020-08-04 02:26:27 +02:00
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
2020-12-12 16:56:08 +01:00
|
|
|
prePatch = ''
|
|
|
|
sed -i s/', "-nostdlibinc"'// builder/builtins.go
|
|
|
|
sed -i s/'"-nostdlibinc", '// compileopts/config.go builder/picolibc.go
|
|
|
|
'';
|
|
|
|
|
2019-12-08 08:00:34 +01:00
|
|
|
subPackages = [ "." ];
|
2021-02-07 10:17:39 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ llvm clang-unwrapped ];
|
2019-12-08 08:00:34 +01:00
|
|
|
propagatedBuildInputs = [ lld avrgcc avrdude openocd gcc-arm-embedded ];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/tinygo
|
|
|
|
cp -a lib src targets $out/share/tinygo
|
2020-12-12 16:56:08 +01:00
|
|
|
wrapProgram $out/bin/tinygo --prefix "TINYGOROOT" : "$out/share/tinygo" \
|
|
|
|
--prefix "PATH" : "$out/libexec/tinygo"
|
|
|
|
mkdir -p $out/libexec/tinygo
|
|
|
|
ln -s ${clang-unwrapped}/bin/clang $out/libexec/tinygo/clang-10
|
|
|
|
ln -s ${lld}/bin/lld $out/libexec/tinygo/ld.lld-10
|
2019-12-08 08:00:34 +01:00
|
|
|
ln -sf $out/bin $out/share/tinygo
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://tinygo.org/";
|
|
|
|
description = "Go compiler for small places";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ chiiruno ];
|
|
|
|
};
|
|
|
|
}
|