From f35e62c9ce13ca63b43da5222cd860212a6eb1ef Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 21 Jun 2019 11:36:55 +0200 Subject: [PATCH] Manage tooling with Nix Enter managed environment by invoking 'nix-shell' at the root of the repository. --- .gitmodules | 4 +-- Tuprules.tup | 12 +++++--- build-x86_64/tup.config | 1 + default.nix | 48 +++++++++++++++++++++++++++++ errata/toolchain.nix | 68 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 default.nix create mode 100644 errata/toolchain.nix diff --git a/.gitmodules b/.gitmodules index 002df138e..b86bf26ee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -15,7 +15,7 @@ url = git://depot.h4ck.me/srv/git/blobsets [submodule "nimble/ninep"] path = nim/ninep - url = git://depot.h4ck.me/srv/git/ehmry/ninep + url = git://depot.h4ck.me/srv/git/ninep [submodule "libretro/libretro-common"] path = libretro/libretro-common url = https://github.com/libretro/libretro-common.git @@ -78,7 +78,7 @@ url = git@github.com:ehmry/fetch_and_copy.git [submodule "nimble/nim"] path = nim/nim - url = https://github.com/nim-lang/nim.git + url = https://github.com/ehmry/nim.git [submodule "nimble/spry_genode"] path = nim/spry_genode url = git@github.com:ehmry/spry_genode.git diff --git a/Tuprules.tup b/Tuprules.tup index f209040be..e7ed3776d 100644 --- a/Tuprules.tup +++ b/Tuprules.tup @@ -101,10 +101,14 @@ ERRATA_DIR = $(TUP_CWD)/errata PKG_CONFIG = PKG_CONFIG_PATH=@(PKG_CONFIG_PATH) pkg-config -CC = @(CC_WRAPPER) `$(PKG_CONFIG) genode-base --variable cc` -CXX = @(CXX_WRAPPER) `$(PKG_CONFIG) genode-base --variable cxx` -LD = `$(PKG_CONFIG) genode-base --variable ld` -AR = `$(PKG_CONFIG) genode-base --variable ar` +ifndef TOOL_CHAIN_PREFIX + error TOOL_CHAIN_PREFIX not configured +endif + +CC = $(TOOL_CHAIN_PREFIX)gcc +CXX = $(TOOL_CHAIN_PREFIX)g++ +LD= $(TOOL_CHAIN_PREFIX)ld +AR = $(TOOL_CHAIN_PREFIX)ar !cc = |> ^ CC %f^ $(CC) $(DEFINES) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -c %f -o %o |> !cxx = |> ^ CC %f^ $(CC) $(DEFINES) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) -c %f -o %o |> diff --git a/build-x86_64/tup.config b/build-x86_64/tup.config index 5dc271007..118e41390 100644 --- a/build-x86_64/tup.config +++ b/build-x86_64/tup.config @@ -1,4 +1,5 @@ CONFIG_TUP_ARCH=x86_64 +CONFIG_TOOL_CHAIN_PREFIX=genode-x86- CONFIG_SCULPT_VERSION=19.05 CONFIG_PKG_CONFIG_PATH=/opt/genode/sdk-19.05/pkgconfig/x86_64 diff --git a/default.nix b/default.nix new file mode 100644 index 000000000..1fc80ec9a --- /dev/null +++ b/default.nix @@ -0,0 +1,48 @@ +{ pkgs ? import {} }: with pkgs; + +pkgs.mkShell { + name = "genode-dev-env"; + nativeBuildInputs = + [ (import ./errata/toolchain.nix { inherit pkgs; }) + stdenv.glibc.dev + git tup + ccache + tcl + gnumake + which + findutils + autoconf264 + autogen + + expect libxml2 syslinux qemu xorriso + + # libc + flex bison + + # virtualbox + yasm libxslt iasl + + # qt5 + gperf + qt5.full + + # ncurses + mawk + + # fb_sdl + pkgconfig + SDL.dev + alsaLib.dev + + # ncurses port needs infocmp + ncurses + ]; + + 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\] " + ''; + # Setup a prompt with a distinct appearance +} diff --git a/errata/toolchain.nix b/errata/toolchain.nix new file mode 100644 index 000000000..2aa0b8d90 --- /dev/null +++ b/errata/toolchain.nix @@ -0,0 +1,68 @@ +{ pkgs ? import {} }: with pkgs; + +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; }; +}