2
0
Fork 0
Browse Source

overlay: refactor helper functions

hybda
Emery Hemingway 2 years ago
parent
commit
0c4c969fa4
  1. 119
      overlay/default.nix

119
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:
if hostPlatform.isGenode then drv.overrideAttrs f else drv;
overrideTarget = attrs: drv:
if targetPlatform.isGenode then drv.override attrs else drv;
overrideTarget = drv: f:
if targetPlatform.isGenode then drv.override f else drv;
overrideAttrsHost = f: drv:
if hostPlatform.isGenode then drv.overrideAttrs 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; };
addPatchesHost = ps: overrideAttrsHost (addPatches' ps);
addPatchesTarget = ps: overrideAttrsTarget (addPatches' ps);
addHostPatches = if hostPlatform.isGenode then
drv: patches:
overrideTargetAttrs drv
(attrs: { patches = attrs.patches or [ ] ++ patches; })
else
drv: _: drv;
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
'';
});
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;
gdb = addPatches gdb [ ./gdb/genode.patch ];
}) cmake;
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 = 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;
libkrb5 = autoreconfHost libkrb5;
libtool = overrideTargetAttrs libtool (attrs: {
nativeBuildInputs = attrs.nativeBuildInputs ++ [ autoconf automake115x ];
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;
}

Loading…
Cancel
Save