2
0
Fork 0
genodepkgs/upstream/default.nix

102 lines
3.0 KiB
Nix
Raw Normal View History

2019-09-13 12:08:40 +02:00
{ nixpkgs }:
2019-07-30 12:48:01 +02:00
let
inherit (nixpkgs.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";
2019-07-30 12:48:01 +02:00
version = "19.07";
buildRepo = repo: nativeBuildInputs:
2019-07-30 12:48:01 +02:00
nixpkgs.stdenv.mkDerivation {
name = "genode-${repo}-${version}";
outputs = [ "out" "dev" ];
inherit repo nativeBuildInputs specs version;
2019-07-30 12:48:01 +02:00
LIBCXX = nixpkgs.llvmPackages.libcxx;
LIBCXXABI = nixpkgs.llvmPackages.libcxxabi;
LIBUNWIND = nixpkgs.llvmPackages.libunwind;
HOST_LIBC = nixpkgs.buildPackages.glibc.dev;
LIBUNWIND_BAREMETAL =
nixpkgs.llvmPackages.libunwind.override { isBaremetal = true; };
src = nixpkgs.fetchgit {
url = "https://git.sr.ht/~ehmry/genode";
2019-09-21 21:53:37 +02:00
rev = "d28abff776f94dc876662eb7dcdf5a6e81d26cc8";
sha256 = "1ibw27s352c2si22y209q17api8gaqv7qsh70vh4wk9bfv1kgchx";
fetchSubmodules = false;
};
setupHook = ./../tool/setup-hooks.sh;
depsBuildBuild = with nixpkgs.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
2019-07-30 12:48:01 +02:00
touch $dev/.genode
for pc in $dev/lib/pkgconfig/*.pc; do
sed -i "s|-l:|$dev/lib/|g" $pc
2019-07-30 12:48:01 +02:00
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" [ base ];
base-nova = buildRepo "base-nova" [ base ];
os = buildRepo "os" [ base ];
2019-07-30 12:48:01 +02:00
}