Nix derivation for upstream build
This commit is contained in:
parent
3c8e393368
commit
d6eedd701c
68
toolchain.nix
Normal file
68
toolchain.nix
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
{ nixpkgs ? import <nixpkgs> {} }: with nixpkgs;
|
||||||
|
|
||||||
|
let
|
||||||
|
genodeVersion = "19.05";
|
||||||
|
glibcVersion = (builtins.parseDrvName stdenv.glibc.name).version;
|
||||||
|
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
name = "genode-toolchain-${genodeVersion}";
|
||||||
|
version = genodeVersion;
|
||||||
|
|
||||||
|
src =
|
||||||
|
if stdenv.isx86_64 then
|
||||||
|
fetchurl {
|
||||||
|
url = "https://downloads.sourceforge.net/project/genode/genode-toolchain/${genodeVersion}/genode-toolchain-${genodeVersion}-x86_64.tar.xz";
|
||||||
|
sha256 = "036czy21zk7fvz1y1p67q3d5hgg8rb8grwabgrvzgdsqcv2ls6l9";
|
||||||
|
}
|
||||||
|
else abort "no toolchain for ${stdenv.system}";
|
||||||
|
|
||||||
|
buildInputs = [ patchelf ];
|
||||||
|
|
||||||
|
dontPatchELF = true;
|
||||||
|
|
||||||
|
# installPhase is disabled for now
|
||||||
|
phases = "unpackPhase fixupPhase";
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
|
||||||
|
echo "unpacking $src..."
|
||||||
|
tar xf $src --strip-components=5 -C $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cd $out/bin
|
||||||
|
for platform in arm x86 ; do
|
||||||
|
dest="$"$platform"/bin"
|
||||||
|
eval dest=$"$dest"
|
||||||
|
|
||||||
|
mkdir -p $dest
|
||||||
|
|
||||||
|
for b in genode-$platform-* ; do
|
||||||
|
eval ln -s $b $dest/$\{b#genode-$platform-\}
|
||||||
|
done
|
||||||
|
|
||||||
|
done
|
||||||
|
cd -
|
||||||
|
'';
|
||||||
|
|
||||||
|
fixupPhase = ''
|
||||||
|
interp=${stdenv.glibc.out}/lib/ld-${glibcVersion}.so
|
||||||
|
if [ ! -f "$interp" ] ; then
|
||||||
|
echo new interpreter $interp does not exist,
|
||||||
|
echo cannot patch binaries
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for f in $(find $out); do
|
||||||
|
if [ -f "$f" ] && patchelf "$f" 2> /dev/null; then
|
||||||
|
patchelf --set-interpreter $interp \
|
||||||
|
--set-rpath $out/lib:${stdenv.glibc.out}/lib:${zlib.out}/lib \
|
||||||
|
"$f" || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru = { libc = stdenv.glibc; };
|
||||||
|
}
|
53
upstream.nix
Normal file
53
upstream.nix
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
{ nixpkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (nixpkgs) stdenv git tup pkg-config;
|
||||||
|
toolchain = import ./tool/toolchain.nix { inherit nixpkgs; };
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "genode";
|
||||||
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
|
src = ./../genode;
|
||||||
|
|
||||||
|
nativeBuildInputs =
|
||||||
|
[ toolchain
|
||||||
|
stdenv.glibc.dev
|
||||||
|
git tup pkg-config
|
||||||
|
];
|
||||||
|
|
||||||
|
configurePhase =
|
||||||
|
''
|
||||||
|
# Populate the SDK headers
|
||||||
|
mkdir -p $out $dev/include $dev/pkg-config $dev/lib
|
||||||
|
cp -r repos/base/src/ld $dev/ld
|
||||||
|
cp -r repos/base/include $dev/include/base
|
||||||
|
cp -r repos/os/include $dev/include/os
|
||||||
|
|
||||||
|
# Use specialized build configuration
|
||||||
|
substitute configs/nix-x86_64.config tup.config \
|
||||||
|
--replace @NIX_DEV_OUTPUT@ $dev \
|
||||||
|
--replace @NIX_DEPOT_VERSION@ `git describe` \
|
||||||
|
|
||||||
|
# Scan repository and generate script
|
||||||
|
mkdir lib
|
||||||
|
tup init
|
||||||
|
tup generate buildPhase.sh
|
||||||
|
|
||||||
|
# Redirect SDK artifacts
|
||||||
|
rm -r depot lib
|
||||||
|
ln -s $out depot
|
||||||
|
ln -s $dev/pkg-config pkg-config
|
||||||
|
ln -s $dev/lib lib
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase =
|
||||||
|
''
|
||||||
|
local HOST_LIBC=${stdenv.glibc.dev}
|
||||||
|
set -v
|
||||||
|
source buildPhase.sh
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Use "genode-base.pc" when not building internals
|
||||||
|
installPhase = "rm $dev/pkg-config/base.pc";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user