From 7a6c54c76ecdf48b34c663a3a2dc9d187e80c0f6 Mon Sep 17 00:00:00 2001 From: Knarkzel Date: Tue, 15 Nov 2022 15:17:21 +0100 Subject: [PATCH] Initial commit --- README.md | 9 +++++ devkitppc/default.nix | 80 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 README.md create mode 100644 devkitppc/default.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..8399e17 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# devkitnix + +Collection of Nix-compatible build scripts for devkitpro. To install toolchain, +use following: + +``` +cd +nix-build . +``` diff --git a/devkitppc/default.nix b/devkitppc/default.nix new file mode 100644 index 0000000..2845a62 --- /dev/null +++ b/devkitppc/default.nix @@ -0,0 +1,80 @@ +{pkgs ? import {}}: +with pkgs; rec { + devkitppc-img = dockerTools.pullImage { + imageName = "devkitpro/devkitppc"; + imageDigest = "sha256:77ed88cb417e057fa805e12a8ce1eab8865fe35a761cde7be00315d5c6cba288"; + sha256 = "LLFLDSPJ/tCRBLj0f9q34b5GVHnHudFCgkb7ppMm8VI="; + finalImageName = "devkitpro/devkitppc"; + finalImageTag = "20200704"; + }; + + # based on + extractDocker = image: dir: + pkgs.vmTools.runInLinuxVM ( + pkgs.runCommand "docker-preload-image" { + buildInputs = [ + docker + e2fsprogs + utillinux + curl + kmod + ]; + memSize = 8 * 1024; + } + + '' + modprobe overlay + + # from https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount + mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup + cd /sys/fs/cgroup + for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do + mkdir -p $sys + if ! mountpoint -q $sys; then + if ! mount -n -t cgroup -o $sys cgroup $sys; then + rmdir $sys || true + fi + fi + done + + dockerd -H tcp://127.0.0.1:5555 -H unix:///var/run/docker.sock & + + until $(curl --output /dev/null --silent --connect-timeout 2 http://127.0.0.1:5555); do + printf '.' + sleep 1 + done + + echo load image + docker load -i ${image} + + echo run image + docker run ${image.destNameTag} tar -C '${toString dir}' -c . | tar -xv --no-same-owner -C $out || true + + echo end + kill %1 + '' + ); + + devkitpro = stdenv.mkDerivation { + name = "devkitpro"; + src = extractDocker devkitppc-img "/opt/devkitpro"; + nativeBuildInputs = [ + autoPatchelfHook + ]; + buildInputs = [ + stdenv.cc.cc + openssl + zlib + libarchive + ncurses5 + expat + tlf + ]; + buildPhase = "true"; + installPhase = '' + mkdir -p $out + cp -r $src/{devkitPPC,libogc,examples,portlibs,tools,wut} $out + rm -rf $out/pacman + ''; + }; +}