2
0
Fork 0
genodepkgs/upstream/default.nix

137 lines
4.0 KiB
Nix
Raw Normal View History

2019-09-27 12:38:35 +02:00
# SPDX-FileCopyrightText: Emery Hemingway
#
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
{ stdenv, buildPackages, fetchgit, llvmPackages }:
2019-07-30 12:48:01 +02:00
let
2019-10-04 14:31:23 +02:00
version = "19.08-64-g69eb762e4a";
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";
2019-07-30 12:48:01 +02:00
buildRepo = repo:
2019-07-30 12:48:01 +02:00
2019-10-04 14:31:23 +02:00
let
tupArch = with stdenv.targetPlatform;
if isAarch32 then "arm" else
if isAarch64 then "arm64" else
if isx86_32 then "i386" else
if isx86_64 then "x86_64" else
abort "unhandled targetPlatform";
toTupConfig = attrs:
with builtins;
let op = config: name: "${config}CONFIG_${name}=${getAttr name attrs} ";
in foldl' op "" (attrNames attrs);
in stdenv.mkDerivation {
name = "genode-${repo}-${version}";
outputs = [ "out" "dev" ];
inherit repo specs version;
2019-07-30 12:48:01 +02:00
src = fetchgit {
url = "https://git.sr.ht/~ehmry/genode";
2019-10-04 14:31:23 +02:00
rev = "69eb762e4a0f00424643411e599bfba46b75795b";
sha256 = "0p7nlk331b921ds94m59fnnl1d3zb719q3kayy2qkr2k6xi0pf17";
fetchSubmodules = false;
};
setupHook = ./../tool/setup-hooks.sh;
depsBuildBuild = with buildPackages; [ llvm pkgconfig tup ];
2019-10-04 14:31:23 +02:00
tupConfig = toTupConfig {
LIBCXX = llvmPackages.libcxx;
LIBCXXABI = llvmPackages.libcxxabi;
LIBUNWIND = llvmPackages.libunwind;
LIBUNWIND_BAREMETAL = llvmPackages.libunwind.override { isBaremetal = true; };
LINUX_HEADERS = buildPackages.glibc.dev;
TUP_ARCH = tupArch;
VERSION = version;
};
configurePhase = ''
# Configure Tup
2019-10-04 14:31:23 +02:00
echo $tupConfig | tr ' CONFIG_' '\nCONFIG_' > 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
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
'';
2019-09-24 12:24:28 +02:00
meta = with stdenv.lib; {
description =
"The Genode operation system framework (${repo} repository).";
homepage = "https://genode.org/";
license = licenses.agpl3;
maintainers = [ maintainers.ehmry ];
};
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\] "
2019-10-04 14:31:23 +02:00
echo $tupConfig | tr ' CONFIG_' '\nCONFIG_'
'';
};
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 ]; });
2019-07-30 12:48:01 +02:00
}