109 lines
3.1 KiB
Nix
109 lines
3.1 KiB
Nix
{ stdenv, buildPackages, fetchgit, llvmPackages }:
|
|
|
|
let
|
|
inherit (stdenv) lib targetPlatform;
|
|
specs = with targetPlatform; []
|
|
++ lib.optional is32bit "32bit"
|
|
++ lib.optional is64bit "64bit"
|
|
++ lib.optional isAarch32 "arm"
|
|
++ lib.optional isAarch64 "arm_64"
|
|
++ lib.optional isRiscV "riscv"
|
|
++ lib.optional isx86 "x86"
|
|
++ lib.optional isx86_32 "x86_32"
|
|
++ lib.optional isx86_64 "x86_64";
|
|
|
|
version = "19.07";
|
|
buildRepo = repo:
|
|
|
|
stdenv.mkDerivation {
|
|
name = "genode-${repo}-${version}";
|
|
outputs = [ "out" "dev" ];
|
|
inherit repo specs version;
|
|
|
|
HOST_LIBC = buildPackages.glibc.dev;
|
|
LIBCXX = llvmPackages.libcxx;
|
|
LIBCXXABI = llvmPackages.libcxxabi;
|
|
LIBUNWIND = llvmPackages.libunwind;
|
|
|
|
LIBUNWIND_BAREMETAL =
|
|
llvmPackages.libunwind.override { isBaremetal = true; };
|
|
|
|
src = fetchgit {
|
|
url = "https://git.sr.ht/~ehmry/genode";
|
|
rev = "d28abff776f94dc876662eb7dcdf5a6e81d26cc8";
|
|
sha256 = "1ibw27s352c2si22y209q17api8gaqv7qsh70vh4wk9bfv1kgchx";
|
|
fetchSubmodules = false;
|
|
};
|
|
|
|
setupHook = ./../tool/setup-hooks.sh;
|
|
|
|
depsBuildBuild = with buildPackages; [ llvm pkgconfig tup ];
|
|
|
|
configurePhase = ''
|
|
# Configure Tup
|
|
echo CONFIG_NIX= >> tup.config
|
|
echo CONFIG_NIX_OUTPUTS_OUT=$out >> tup.config
|
|
echo CONFIG_NIX_OUTPUTS_DEV=$dev >> tup.config
|
|
|
|
# Disable other repos
|
|
for R in repos/*; do
|
|
[ "$R" != "repos/$repo" ] && find $R -name Tupfile -delete
|
|
done
|
|
find repos/gems -name Tupfile -delete
|
|
|
|
# Scan repository and generate script
|
|
rm Tupfile # skip the dhall stuff
|
|
tup init
|
|
tup generate buildPhase.sh
|
|
|
|
# Redirect artifacts to Nix store
|
|
mkdir -p $out $dev/include
|
|
ln -s $out out
|
|
ln -s $dev dev
|
|
'';
|
|
|
|
buildPhase = ''
|
|
test -d repos/$repo/src/ld && cp -rv repos/$repo/src/ld $dev/
|
|
pushd .
|
|
set -v
|
|
source buildPhase.sh
|
|
set +v
|
|
popd
|
|
'';
|
|
|
|
installPhase = ''
|
|
# Populate the "dev" headers
|
|
for DIR in repos/$repo/include; do
|
|
for SPEC in $specs; do
|
|
if [ -d $DIR/spec/$SPEC ]; then
|
|
cp -r $DIR/spec/$SPEC/* $dev/include
|
|
rm -r $DIR/spec/$SPEC
|
|
fi
|
|
done
|
|
rm -rf $DIR/spec
|
|
cp -r $DIR $dev/
|
|
done
|
|
|
|
touch $dev/.genode
|
|
for pc in $dev/lib/pkgconfig/*.pc; do
|
|
sed -i "s|-l:|$dev/lib/|g" $pc
|
|
done
|
|
'';
|
|
|
|
shellHook = ''
|
|
export PROMPT_DIRTRIM=2
|
|
export PS1="\[\033[1;30m\]Genode-dev [\[\033[1;37m\]\w\[\033[1;30m\]] $\[\033[0m\] "
|
|
export PS2="\[\033[1;30m\]>\[\033[0m\] "
|
|
'';
|
|
};
|
|
|
|
in rec {
|
|
base = buildRepo "base";
|
|
base-linux = (buildRepo "base-linux").overrideAttrs
|
|
(attrs: { nativeBuildInputs = [ base ]; });
|
|
base-nova = (buildRepo "base-nova").overrideAttrs
|
|
(attrs: { nativeBuildInputs = [ base ]; });
|
|
os =
|
|
(buildRepo "os").overrideAttrs (attrs: { nativeBuildInputs = [ base ]; });
|
|
}
|