diff --git a/overlay/default.nix b/overlay/default.nix index a4bb72a..667c692 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -3,43 +3,44 @@ final: prev: with prev; let - overrideHost = drv: attrs: + # Helper functions to override package dependant + # on whether the host or target system is Genode. + + overrideHost = attrs: drv: if hostPlatform.isGenode then drv.override attrs else drv; - overrideHostAttrs = drv: f: + overrideTarget = attrs: drv: + if targetPlatform.isGenode then drv.override attrs else drv; + + overrideAttrsHost = f: drv: if hostPlatform.isGenode then drv.overrideAttrs f else drv; - overrideTarget = drv: f: - if targetPlatform.isGenode then drv.override f else drv; - - overrideTargetAttrs = drv: f: + overrideAttrsTarget = f: drv: if targetPlatform.isGenode then drv.overrideAttrs f else drv; - addPatches = drv: patch: - overrideTargetAttrs drv - (attrs: { patches = attrs.patches or [ ] ++ [ patch ]; }); + addPatches' = patches: attrs: { patches = attrs.patches or [ ] ++ patches; }; - addHostPatches = if hostPlatform.isGenode then - drv: patches: - overrideTargetAttrs drv - (attrs: { patches = attrs.patches or [ ] ++ patches; }) - else - drv: _: drv; + addPatchesHost = ps: overrideAttrsHost (addPatches' ps); + + addPatchesTarget = ps: overrideAttrsTarget (addPatches' ps); + + autoreconfHost = overrideAttrsHost + (attrs: { nativeBuildInputs = [ final.autoreconfHook ]; }); in { - bash = overrideTargetAttrs bash (attrs: { + bash = overrideAttrsTarget (attrs: { configureFlags = attrs.configureFlags ++ [ "--without-bash-malloc" ]; # no sbrk please postPatch = "sed '/check_dev_tty/d' shell.c"; - }); + }) bash; - binutils-unwrapped = overrideTargetAttrs binutils-unwrapped (attrs: { + binutils-unwrapped = overrideAttrsTarget (attrs: { patches = attrs.patches ++ [ ./binutils/support-genode.patch ]; nativeBuildInputs = [ final.updateAutotoolsGnuConfigScriptsHook ]; - }); + }) binutils-unwrapped; - cmake = overrideTargetAttrs cmake (attrs: { + cmake = overrideAttrsTarget (attrs: { postInstall = with stdenv; '' local MODULE="$out/share/cmake-${ lib.versions.majorMinor attrs.version @@ -50,27 +51,24 @@ in { fi cp ${./cmake/Genode.cmake} $MODULE ''; - }); + }) cmake; - coreutils = if targetPlatform.isGenode then - (coreutils.override { - gmp = null; - libiconv = null; - }).overrideAttrs (attrs: { - configureFlags = [ - "--disable-acl" - "--disable-largefile" - "--disable-xattr" - "--disable-libcap" - "--disable-nls" - ]; - LDFLAGS = [ "-Wl,--no-as-needed" ]; - # keep libposix NEEDED - }) - else - coreutils; + coreutils = overrideHost { + gmp = null; + libiconv = null; + } (overrideAttrsHost (attrs: { + configureFlags = [ + "--disable-acl" + "--disable-largefile" + "--disable-xattr" + "--disable-libcap" + "--disable-nls" + ]; + LDFLAGS = [ "-Wl,--no-as-needed" ]; + # keep libposix NEEDED + }) coreutils); - gdb = addPatches gdb [ ./gdb/genode.patch ]; + gdb = addPatchesTarget [ ./gdb/genode.patch ] gdb; genodeLibcCross = callPackage ./libc { }; @@ -78,9 +76,9 @@ in { inherit flake; pkgs = final; }; - - libconfig = overrideHostAttrs libconfig - (attrs: { configureFlags = [ "--disable-examples" ]; }); + libconfig = + overrideAttrsHost (attrs: { configureFlags = [ "--disable-examples" ]; }) + libconfig; libcCrossChooser = name: if stdenv.targetPlatform.isGenode then @@ -88,20 +86,22 @@ in { else prev.libcCrossChooser name; - libsodium = overrideHostAttrs libsodium (attrs: { + libsodium = overrideAttrsHost (attrs: { patches = (attrs.patches or [ ]) ++ [ ./libsodium/genode.patch ]; - }); + }) libsodium; - libtool = overrideTargetAttrs libtool (attrs: { - nativeBuildInputs = attrs.nativeBuildInputs ++ [ autoconf automake115x ]; + libkrb5 = autoreconfHost libkrb5; + + libtool = overrideAttrsTarget (attrs: { + nativeBuildInputs = with final; + attrs.nativeBuildInputs ++ [ autoconf automake115x ]; patches = ./libtool/genode.patch; - }); + }) libtool; - libtoxcore = overrideHost libtoxcore { + libtoxcore = overrideHost { libopus = null; libvpx = null; - ncurses = null; - }; + } libtoxcore; llvmPackages_11 = callPackage ./llvm-11 ({ inherit (stdenvAdapters) overrideCC; @@ -113,9 +113,9 @@ in { stdenv = gcc7Stdenv; }); - ncurses = addHostPatches ncurses [ ./ncurses/genode.patch ]; + ncurses = addPatchesHost [ ./ncurses/genode.patch ] ncurses; - openssl = overrideHostAttrs openssl (attrs: { + openssl = overrideAttrsHost (attrs: { outputs = [ "out" ] ++ builtins.filter (x: x != "bin" && x != "out") attrs.outputs; patches = attrs.patches or [ ] ++ [ ./openssl/genode.patch ]; @@ -126,21 +126,22 @@ in { configureFlags = attrs.configureFlags ++ [ "no-devcryptoeng" ]; postInstall = "rm $out/bin/c_rehash"; # eliminate the perl runtime dependency - }); + }) openssl; - rsync = overrideHostAttrs (overrideHost rsync { + rsync = overrideHost { enableACLs = false; popt = null; - }) (attrs: { outputs = [ "out" "man" ]; }); + } (overrideAttrsHost (attrs: { outputs = [ "out" "man" ]; }) rsync); solo5-tools = callPackage ./solo5-tools { }; - zlib = overrideHostAttrs zlib (attrs: { + zlib = overrideAttrsHost (attrs: { postInstall = attrs.postInstall or "" + '' pushd ''${!outputLib}/lib find . -type l -delete mv libz.so.* libz.so popd ''; - }); + }) zlib; + }