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