diff --git a/default.nix b/default.nix index 1f1e604..5058333 100644 --- a/default.nix +++ b/default.nix @@ -14,6 +14,7 @@ let }; portIncludes = ports: + with builtins; listToAttrs (map (name: let port = getAttr name ports; in { diff --git a/overlay/default.nix b/overlay/default.nix index 1b101d8..619b7de 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -1,20 +1,22 @@ self: super: let - inherit (super) lib stdenv; + inherit (super) lib; - genodeTarget = stdenv.targetPlatform ? isGenode - -> stdenv.targetPlatform.isGenode; + hasGenode = with super.stdenv; + (if hostPlatform ? isGenode then hostPlatform.isGenode else false) + || (if targetPlatform ? isGenode then targetPlatform.isGenode else false); genodelibc = self.callPackage ./libc { stdenv = self.crossLibcStdenv; }; in { - binutils-unwrapped = super.binutils-unwrapped.overrideAttrs - (attrs: { patches = attrs.patches ++ [ ./binutils.patch ]; }); + binutils-unwrapped = super.binutils-unwrapped.overrideAttrs (attrs: { + patches = attrs.patches ++ (lib.optional hasGenode ./binutils.patch); + }); cmake = super.cmake.overrideAttrs (attrs: { - postInstall = if genodeTarget then '' + postInstall = if hasGenode then '' local MODULE="$out/share/cmake-${ lib.versions.majorMinor attrs.version }/Modules/Platform/Genode.cmake" @@ -43,7 +45,7 @@ in { postUnpack = attrs.postUnpack + '' patch -p1 -d $(ls -d llvm-*) -i ${./llvm-genode.patch} ''; - cmakeFlags = attrs.cmakeFlags ++ (lib.optionals genodeTarget [ + cmakeFlags = attrs.cmakeFlags ++ (lib.optionals hasGenode [ "-DCMAKE_C_FLAGS=-nodefaultlibs" "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF" "-DLIBCXXABI_ENABLE_THREADS=OFF" @@ -57,16 +59,16 @@ in { libcxx = (super.llvmPackages_8.libcxx.override { enableShared = false; }).overrideAttrs (attrs: { - patches = attrs.patches ++ (lib.optional genodeTarget ./libc++.patch); + patches = attrs.patches ++ (lib.optional hasGenode ./libc++.patch); nativeBuildInputs = attrs.nativeBuildInputs ++ [ super.buildPackages.python ]; cmakeFlags = attrs.cmakeFlags - ++ (lib.optional genodeTarget "-DLIBCXX_ENABLE_THREADS=OFF"); + ++ (lib.optional hasGenode "-DLIBCXX_ENABLE_THREADS=OFF"); }); clang-unwrapped = super.llvmPackages_8.clang-unwrapped.overrideAttrs (attrs: { - patches = attrs.patches ++ (lib.optional genodeTarget ./clang.patch); + patches = attrs.patches ++ [ ./clang.patch ]; }); };