sigil/overlay/default.nix

308 lines
8.7 KiB
Nix
Raw Normal View History

final: prev:
with prev;
let
# Helper functions to override package dependent
2020-11-26 12:11:29 +01:00
# on whether the host or target system is Genode.
overrideHost = attrs: drv:
if stdenv.hostPlatform.isGenode then drv.override attrs else drv;
2020-10-19 23:04:41 +02:00
2020-11-26 12:11:29 +01:00
overrideAttrsHost = f: drv:
if stdenv.hostPlatform.isGenode then drv.overrideAttrs f else drv;
2020-11-26 12:11:29 +01:00
overrideAttrsTarget = f: drv:
if stdenv.targetPlatform.isGenode then drv.overrideAttrs f else drv;
2020-11-26 12:11:29 +01:00
addPatches' = patches: attrs: { patches = attrs.patches or [ ] ++ patches; };
addPatchesHost = ps: overrideAttrsHost (addPatches' ps);
addPatchesTarget = ps: overrideAttrsTarget (addPatches' ps);
autoreconfHost =
overrideAttrsHost (_: { nativeBuildInputs = [ final.autoreconfHook ]; });
2020-11-25 21:06:52 +01:00
2021-01-05 15:11:42 +01:00
nullPkgs =
2021-03-09 21:43:23 +01:00
# Nullify these packages to find problems early.
if stdenv.hostPlatform.isGenode then
2021-01-05 15:11:42 +01:00
builtins.listToAttrs (map (name: {
inherit name;
value = final.hello;
}) [ "iproute2" "strace" ])
2021-01-05 15:11:42 +01:00
else
{ };
in nullPkgs // {
2020-03-24 13:47:30 +01:00
2020-11-26 12:11:29 +01:00
bash = overrideAttrsTarget (attrs: {
configureFlags = attrs.configureFlags
++ [ "--without-bash-malloc" ]; # no sbrk please
2020-06-08 08:55:57 +02:00
postPatch = "sed '/check_dev_tty/d' shell.c";
}) prev.bash;
2020-03-24 13:47:30 +01:00
2020-11-26 12:11:29 +01:00
binutils-unwrapped = overrideAttrsTarget (attrs: {
2021-03-09 21:43:23 +01:00
patches = attrs.patches ++ [
./binutils/support-genode.patch
# Upstreamed, remove at next release.
];
nativeBuildInputs = attrs.nativeBuildInputs
++ [ final.updateAutotoolsGnuConfigScriptsHook ];
}) prev.binutils-unwrapped;
2021-03-09 21:43:23 +01:00
cmake =
# TODO: upstream
overrideAttrsTarget (attrs: {
postInstall = with stdenv; ''
local MODULE="$out/share/cmake-${
lib.versions.majorMinor attrs.version
}/Modules/Platform/Genode.cmake"
if [ -e "$MODULE" ]; then
echo "Upstream provides $MODULE!"
exit 1
fi
cp ${./cmake/Genode.cmake} $MODULE
'';
}) prev.cmake;
2020-11-26 12:11:29 +01:00
coreutils = overrideHost {
gmp = null;
libiconv = null;
} (overrideAttrsHost (_: {
2020-11-26 12:11:29 +01:00
configureFlags = [
"--disable-acl"
"--disable-largefile"
"--disable-xattr"
"--disable-libcap"
"--disable-nls"
];
LDFLAGS = [ "-Wl,--no-as-needed" ];
# keep libposix NEEDED
}) prev.coreutils);
2020-11-26 12:11:29 +01:00
erisPatchHook =
final.buildPackages.nimPackages.callPackage ./eris-patch-hook {
patchelf = prev.patchelf.overrideAttrs (attrs: {
patches = attrs.patches or [ ] ++ [
./patchelf/dynstr.patch
./patchelf/shiftFile.patch
./patchelf/disable-assert.patch
./patchelf/rpath.patch
];
});
};
2020-04-05 18:50:52 +02:00
genodeLibcCross = callPackage ./libc { };
2021-03-09 21:43:23 +01:00
genodePackages =
# The Genode-only packages.
import ../packages { inherit final prev; };
getdns = overrideHost { doxygen = null; } prev.getdns;
2021-03-09 21:43:23 +01:00
grub2 =
# No need for a Genode build of GRUB.
if stdenv.targetPlatform.isGenode then
prev.buildPackages.grub2
else
prev.grub2;
2020-03-24 13:47:30 +01:00
libcCrossChooser = name:
if stdenv.targetPlatform.isGenode then
final.genodeLibcCross
2020-03-24 13:47:30 +01:00
else
prev.libcCrossChooser name;
libsodium = overrideAttrsHost (_: {
2021-03-09 21:43:23 +01:00
patches = (attrs.patches or [ ]) ++ [
./libsodium/genode.patch
# https://github.com/jedisct1/libsodium/pull/1006
];
}) prev.libsodium;
2020-11-26 12:11:29 +01:00
2021-03-09 21:43:23 +01:00
libkrb5 =
# Do not want.
autoreconfHost prev.libkrb5;
2020-11-01 20:23:01 +01:00
2021-03-09 21:43:23 +01:00
libtool =
# Autotools related nonesense. Better to compile
# everything static than to deal with this one.
overrideAttrsTarget ({ nativeBuildInputs, ... }: {
2021-03-09 21:43:23 +01:00
nativeBuildInputs = with final;
nativeBuildInputs ++ [ autoconf automake115x ];
2021-03-09 21:43:23 +01:00
patches = ./libtool/genode.patch;
}) prev.libtool;
2020-11-26 12:11:29 +01:00
libtoxcore = overrideHost {
2020-11-01 20:23:01 +01:00
libopus = null;
libvpx = null;
} prev.libtoxcore;
2020-11-01 20:23:01 +01:00
2021-03-09 21:43:23 +01:00
linuxPackages =
# Dummy package.
if stdenv.hostPlatform.isGenode then {
2021-03-09 21:43:23 +01:00
extend = _: final.linuxPackages;
features = { };
kernel = {
version = "999";
config = {
isEnabled = _: false;
isYes = _: false;
};
2021-03-09 21:43:23 +01:00
};
} else
prev.linuxPackages;
2021-03-09 21:43:23 +01:00
llvmPackages = if stdenv.targetPlatform.isGenode then
final.llvmPackages_11
else
prev.llvmPackages;
llvmPackages_11 = (import ./llvm-11/override.nix { inherit final prev; });
2021-03-09 21:43:23 +01:00
ncurses =
# https://invisible-island.net/autoconf/
# Stay clear of upstream on this one.
addPatchesHost [ ./ncurses/genode.patch ] prev.ncurses;
2021-03-09 21:43:23 +01:00
2022-10-20 21:33:18 +02:00
nimNoLibs = nim.override { stdenv = stdenvNoLibs; };
nimPackages =
# Packages from the Nimble flake with adjustments.
2022-10-20 21:33:18 +02:00
prev.nimPackages.overrideScope' (final': prev':
with final'; {
buildNimPackage = if stdenv.hostPlatform.isGenode then
2022-10-20 21:33:18 +02:00
({ nimFlags ? [ ], ... }@args:
prev'.buildNimPackage (args // {
nimBackend = "cpp";
nimDefines.posix = { };
doCheck = false;
}))
else
prev'.buildNimPackage;
2023-09-21 19:51:23 +02:00
cbor = buildNimPackage rec {
pname = "cbor";
version = "20230619";
src = fetchFromSourcehut {
owner = "~ehmry";
repo = "nim_${pname}";
rev = version;
hash = "sha256-F6T/5bUwrJyhRarTWO9cjbf7UfEOXPNWu6mfVKNZsQA=";
};
};
2022-10-20 21:33:18 +02:00
dhall = buildNimPackage rec {
pname = "dhall";
2023-09-28 13:16:20 +02:00
version = "20230928";
src = prev.fetchFromSourcehut {
owner = "~ehmry";
repo = "${pname}-nim";
2023-09-28 13:16:20 +02:00
rev = version;
hash = "sha256-IoSA6yVFiAXuoApjWiz4DohnenlQdTAhfE3VeMSZKtM=";
};
2023-09-21 19:51:23 +02:00
propagatedBuildInputs = [ cbor ];
};
2022-10-20 21:33:18 +02:00
genode = prev'.genode.overrideAttrs ({ ... }: rec {
version = "20221020";
src = final.fetchFromSourcehut {
owner = "~ehmry";
repo = "nim_genode";
rev = version;
hash = "sha256-kUbhYKoN/H/fP7ekDYY5rZwZY8UDdcbFBEodthFkmYk=";
};
});
preserves = overrideAttrsTarget ({ ... }: rec {
pname = "preserves";
version = "20221020";
src = final.fetchFromGitea {
domain = "git.syndicate-lang.org";
owner = "ehmry";
repo = "${pname}-nim";
rev = version;
sha256 = "sha256-yUyt4hAKvEKTFV9KF8994k7RrirQQJ2Jv7ngjbnfXgw=";
};
dontFixup = true; # this is breaking input propagation?
}) prev'.preserves;
syndicate = overrideAttrsTarget ({ ... }: {
dontFixup = true; # this is breaking input propagation?
}) prev'.syndicate;
2022-10-20 21:33:18 +02:00
});
2020-12-03 12:49:39 +01:00
openssl =
overrideHost { static = true; } # shared library comes out stupid big
(overrideAttrsHost (attrs: {
outputs = [ "out" ]
++ builtins.filter (x: x != "bin" && x != "out") attrs.outputs;
patches = attrs.patches or [ ] ++ [ ./openssl/genode.patch ];
configureScript = {
2022-04-24 08:35:10 +02:00
x86_64-genode = "./Configure genode-x86_64";
aarch64-genode = "./Configure genode-aarch64";
2020-12-03 12:49:39 +01:00
}.${stdenv.hostPlatform.system} or (throw
"Not sure what configuration to use for ${stdenv.hostPlatform.config}");
configureFlags = attrs.configureFlags ++ [ "no-devcryptoeng" ];
postInstall =
"rm $out/bin/c_rehash"; # eliminate the perl runtime dependency
}) prev.openssl);
2021-03-09 21:43:23 +01:00
patchelf = addPatchesTarget [
./patchelf/dynstr.patch
# Patch to fix a bug in rewriting the .dynstr section.
] prev.patchelf;
readelferislinks =
final.nimPackages.callPackage ../packages/readelferislinks { };
2020-11-26 12:11:29 +01:00
rsync = overrideHost {
enableACLs = false;
popt = null;
} (overrideAttrsHost (_: { outputs = [ "out" "man" ]; }) rsync);
solo5-tools = callPackage ./solo5-tools { };
stdenv = if prev.stdenv.hostPlatform.isGenode then
stdenv.override (prev': {
extraNativeBuildInputs = prev'.extraNativeBuildInputs
++ [ final.buildPackages.erisPatchHook ];
})
else
prev.stdenv;
2020-12-03 12:22:18 +01:00
tor = overrideAttrsHost (attrs: {
2021-03-09 21:43:23 +01:00
patches = attrs.patches or [ ] ++ [
./tor/genode.patch
# We don't do users and groups here.
];
2020-12-03 12:22:18 +01:00
postPatch = null; # Avoid torsocks patching
}) prev.tor;
2020-12-03 12:22:18 +01:00
2020-11-26 12:11:29 +01:00
zlib = overrideAttrsHost (attrs: {
2020-06-10 18:21:26 +02:00
postInstall = attrs.postInstall or "" + ''
pushd ''${!outputLib}/lib
find . -type l -delete
mv libz.so.* libz.so
popd
'';
}) prev.zlib;
2020-11-26 12:11:29 +01:00
2021-04-10 13:33:26 +02:00
zstd = let
static = true;
legacySupport = false;
in overrideAttrsHost (_: rec {
2021-04-10 13:33:26 +02:00
cmakeFlags = lib.attrsets.mapAttrsToList
(name: value: "-DZSTD_${name}:BOOL=${if value then "ON" else "OFF"}") {
BUILD_SHARED = !static;
BUILD_STATIC = static;
PROGRAMS_LINK_SHARED = !static;
LEGACY_SUPPORT = legacySupport;
BUILD_TESTS = doCheck;
};
doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
}) prev.zstd;
}